Skip to content

Commit

Permalink
Add serialize tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed May 28, 2024
1 parent 816c70e commit 333acfa
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions py-polars/tests/unit/dataframe/test_serde.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import pytest

import polars as pl


def test_df_serialize() -> None:
df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}).sort("a")
result = df.serialize()
expected = '{"columns":[{"name":"a","datatype":"Int64","bit_settings":"SORTED_ASC","values":[1,2,3]},{"name":"b","datatype":"Int64","bit_settings":"","values":[4,5,6]}]}'
assert result == expected


def test_df_write_json_deprecated() -> None:
df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
with pytest.deprecated_call():
result = df.write_json()
assert result == df.serialize()


def test_df_write_json_pretty_deprecated() -> None:
df = pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
with pytest.deprecated_call():
result = df.write_json(pretty=True)
assert isinstance(result, str)

0 comments on commit 333acfa

Please sign in to comment.