diff --git a/py-polars/tests/unit/datatypes/test_string.py b/py-polars/tests/unit/datatypes/test_string.py new file mode 100644 index 000000000000..ce63c4b6b79c --- /dev/null +++ b/py-polars/tests/unit/datatypes/test_string.py @@ -0,0 +1,30 @@ +import polars as pl +from polars.testing import assert_series_equal + + +def test_series_init_string() -> None: + s = pl.Series(["a", "b"]) + assert s.dtype == pl.String + + +def test_utf8_alias_eq() -> None: + assert pl.Utf8 == pl.String + assert pl.Utf8 == pl.String() + assert pl.Utf8() == pl.String + assert pl.Utf8() == pl.String() + + +def test_utf8_alias_hash() -> None: + assert hash(pl.Utf8) == hash(pl.String) + assert hash(pl.Utf8()) == hash(pl.String()) + + +def test_utf8_alias_series_init() -> None: + s = pl.Series(["a", "b"], dtype=pl.Utf8) + assert s.dtype == pl.String + + +def test_utf8_alias_lit() -> None: + result = pl.select(a=pl.lit(5, dtype=pl.Utf8)).to_series() + expected = pl.Series("a", ["5"], dtype=pl.String) + assert_series_equal(result, expected) diff --git a/py-polars/tests/unit/interchange/test_utils.py b/py-polars/tests/unit/interchange/test_utils.py index b4469c695f51..9f837b7049b2 100644 --- a/py-polars/tests/unit/interchange/test_utils.py +++ b/py-polars/tests/unit/interchange/test_utils.py @@ -29,6 +29,7 @@ (pl.Float64, (DtypeKind.FLOAT, 64, "g", NE)), (pl.Boolean, (DtypeKind.BOOL, 1, "b", NE)), (pl.String, (DtypeKind.STRING, 8, "U", NE)), + (pl.Utf8, (DtypeKind.STRING, 8, "U", NE)), (pl.Date, (DtypeKind.DATETIME, 32, "tdD", NE)), (pl.Time, (DtypeKind.DATETIME, 64, "ttu", NE)), (pl.Categorical, (DtypeKind.CATEGORICAL, 32, "I", NE)),