From 73cf244e8f26f4807080cd280300fc50306d1e4a Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:06:58 +0000 Subject: [PATCH] add tests --- tests/pickle_test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/pickle_test.py diff --git a/tests/pickle_test.py b/tests/pickle_test.py new file mode 100644 index 000000000..78c0debf9 --- /dev/null +++ b/tests/pickle_test.py @@ -0,0 +1,23 @@ +from __future__ import annotations + +from dataclasses import asdict +from dataclasses import dataclass +from typing import Sequence + +import pandas as pd +import polars as pl + +import narwhals.stable.v1 as nw + + +def test_dataclass() -> None: + # https://github.com/narwhals-dev/narwhals/issues/1486 + @dataclass + class Foo: + a: Sequence[int] + + # dry-run to check that none of these error + asdict(Foo(pd.Series([1, 2, 3]))) + asdict(Foo(pl.Series([1, 2, 3]))) # type: ignore[arg-type] + asdict(Foo(nw.from_native(pl.Series([1, 2, 3]), series_only=True))) # type: ignore[arg-type] + asdict(Foo(nw.from_native(pd.Series([1, 2, 3]), series_only=True))) # type: ignore[arg-type]