Skip to content

Commit

Permalink
Add testcase for #20766
Browse files Browse the repository at this point in the history
  • Loading branch information
bschoenmaeckers committed Jan 22, 2025
1 parent 2c139c9 commit a242bd7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions py-polars/tests/unit/constructors/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,35 @@ def test_init_list_of_dicts_with_timezone(tz: Any) -> None:
assert df.schema == {"dt": pl.Datetime("us", time_zone=tz)}


@pytest.mark.parametrize(
"tz",
[
None,
ZoneInfo("Asia/Tokyo"),
ZoneInfo("Europe/Amsterdam"),
ZoneInfo("UTC"),
timezone.utc,
],
)
def test_init_list_of_nested_dicts_with_timezone(tz: Any) -> None:
dt = datetime(2021, 1, 1, 0, 0, 0, 0, tzinfo=tz)
data = [
{
"timestamp": {
"content": datetime(
2021, 1, 1, 0, 0, tzinfo=tz
)
}
}
]

df = pl.DataFrame(data).unnest("timestamp")
expected = pl.DataFrame({"content": [dt]})
assert_frame_equal(df, expected)

assert df.schema == {"content": pl.Datetime("us", time_zone=tz)}


def test_init_from_subclassed_types() -> None:
# more detailed test of one custom subclass...
import codecs
Expand Down

0 comments on commit a242bd7

Please sign in to comment.