|
7 | 7 | import pytest |
8 | 8 |
|
9 | 9 | import narwhals as nw |
10 | | -from tests.utils import Constructor, ConstructorEager, assert_equal_data |
| 10 | +from tests.utils import POLARS_VERSION, Constructor, ConstructorEager, assert_equal_data |
11 | 11 |
|
12 | 12 | data = { |
13 | 13 | "a": [datetime(2021, 3, 1, 12, 34, 56, 49012), datetime(2020, 1, 2, 2, 4, 14, 715123)] |
@@ -54,9 +54,13 @@ def test_truncate( |
54 | 54 | expected: list[datetime], |
55 | 55 | ) -> None: |
56 | 56 | if every.endswith("ns") and any( |
57 | | - x in str(constructor) for x in ("polars", "duckdb", "pyspark", "ibis") |
| 57 | + x in str(constructor) for x in ("duckdb", "pyspark", "ibis") |
58 | 58 | ): |
59 | 59 | request.applymarker(pytest.mark.xfail()) |
| 60 | + |
| 61 | + if every.endswith("ns") and "polars" in str(constructor) and POLARS_VERSION < (1, 35): |
| 62 | + request.applymarker(pytest.mark.xfail()) |
| 63 | + |
60 | 64 | if any(every.endswith(x) for x in ("mo", "q", "y")) and any( |
61 | 65 | x in str(constructor) for x in ("dask", "cudf") |
62 | 66 | ): |
@@ -109,14 +113,16 @@ def test_truncate_multiples( |
109 | 113 | # - cudf: https://github.com/rapidsai/cudf/issues/18654 |
110 | 114 | # - pyspark/sqlframe: Only multiple 1 is currently supported |
111 | 115 | request.applymarker(pytest.mark.xfail()) |
112 | | - if every.endswith("ns") and any( |
113 | | - x in str(constructor) for x in ("polars", "duckdb", "ibis") |
114 | | - ): |
| 116 | + |
| 117 | + if every.endswith("ns") and any(x in str(constructor) for x in ("duckdb", "ibis")): |
115 | 118 | request.applymarker(pytest.mark.xfail()) |
116 | | - if any(every.endswith(x) for x in ("mo", "q", "y")) and any( |
117 | | - x in str(constructor) for x in ("dask",) |
118 | | - ): |
| 119 | + |
| 120 | + if every.endswith("ns") and "polars" in str(constructor) and POLARS_VERSION < (1, 35): |
| 121 | + request.applymarker(pytest.mark.xfail()) |
| 122 | + |
| 123 | + if any(every.endswith(x) for x in ("mo", "q", "y")) and "dask" in str(constructor): |
119 | 124 | request.applymarker(pytest.mark.xfail(reason="Not implemented")) |
| 125 | + |
120 | 126 | df = nw.from_native(constructor(data)) |
121 | 127 | result = df.select(nw.col("a").dt.truncate(every)) |
122 | 128 | assert_equal_data(result, {"a": expected}) |
|
0 commit comments