17
17
from tests .utils import Constructor
18
18
from tests .utils import ConstructorEager
19
19
from tests .utils import assert_equal_data
20
- from tests .utils import is_windows
20
+ from tests .utils import is_pyarrow_windows_no_tzdata
21
21
22
22
if TYPE_CHECKING :
23
23
from narwhals .typing import IntoSeriesT
@@ -55,15 +55,17 @@ def test_timestamp_datetimes(
55
55
expected : list [int | None ],
56
56
) -> None :
57
57
if any (x in str (constructor ) for x in ("duckdb" , "pyspark" )):
58
- request .applymarker (pytest .mark .xfail )
58
+ request .applymarker (
59
+ pytest .mark .xfail (reason = "Backend timestamp conversion not yet implemented" )
60
+ )
59
61
if original_time_unit == "s" and "polars" in str (constructor ):
60
- request .applymarker (pytest .mark .xfail )
62
+ pytest .skip ("Second precision not supported in Polars" )
63
+
61
64
if "pandas_pyarrow" in str (constructor ) and PANDAS_VERSION < (
62
65
2 ,
63
66
2 ,
64
67
): # pragma: no cover
65
- # pyarrow-backed timestamps were too inconsistent and unreliable before 2.2
66
- request .applymarker (pytest .mark .xfail (strict = False ))
68
+ pytest .skip ("Requires pandas >= 2.2 for reliable pyarrow-backed timestamps" )
67
69
datetimes = {"a" : [datetime (2001 , 1 , 1 ), None , datetime (2001 , 1 , 3 )]}
68
70
df = nw .from_native (constructor (datetimes ))
69
71
result = df .select (
@@ -97,27 +99,38 @@ def test_timestamp_datetimes_tz_aware(
97
99
expected : list [int | None ],
98
100
) -> None :
99
101
if any (x in str (constructor ) for x in ("duckdb" , "pyspark" )):
100
- request .applymarker (pytest .mark .xfail )
101
- if (
102
- (any (x in str (constructor ) for x in ("pyarrow" ,)) and is_windows ())
103
- or ("pandas_pyarrow" in str (constructor ) and PANDAS_VERSION < (2 ,))
104
- or ("pyarrow_table" in str (constructor ) and PYARROW_VERSION < (12 ,))
105
- ):
106
- request .applymarker (pytest .mark .xfail )
107
- if "pandas_pyarrow" in str (constructor ) and PANDAS_VERSION < (
108
- 2 ,
109
- 2 ,
110
- ): # pragma: no cover
111
- # pyarrow-backed timestamps were too inconsistent and unreliable before 2.2
112
- request .applymarker (pytest .mark .xfail (strict = False ))
113
- if "dask" in str (constructor ) and PANDAS_VERSION < (
114
- 2 ,
115
- 1 ,
116
- ): # pragma: no cover
117
- request .applymarker (pytest .mark .xfail )
102
+ request .applymarker (
103
+ pytest .mark .xfail (reason = "Backend timestamp conversion not yet implemented" )
104
+ )
105
+ version_conditions = [
106
+ (
107
+ is_pyarrow_windows_no_tzdata (constructor ),
108
+ "Timezone database is not installed on Windows" ,
109
+ ),
110
+ (
111
+ "pandas_pyarrow" in str (constructor ) and PANDAS_VERSION < (2 ,),
112
+ "Requires pandas >= 2.0 for pyarrow support" ,
113
+ ),
114
+ (
115
+ "pyarrow_table" in str (constructor ) and PYARROW_VERSION < (12 ,),
116
+ "Requires pyarrow >= 12.0" ,
117
+ ),
118
+ (
119
+ "pandas_pyarrow" in str (constructor ) and PANDAS_VERSION < (2 , 2 ),
120
+ "Requires pandas >= 2.2 for reliable timestamps" ,
121
+ ),
122
+ (
123
+ "dask" in str (constructor ) and PANDAS_VERSION < (2 , 1 ),
124
+ "Requires pandas >= 2.1 for dask support" ,
125
+ ),
126
+ ]
127
+
128
+ for condition , reason in version_conditions :
129
+ if condition :
130
+ pytest .skip (reason ) # pragma: no cover
118
131
119
132
if original_time_unit == "s" and "polars" in str (constructor ):
120
- request .applymarker (pytest .mark .xfail )
133
+ request .applymarker (pytest .mark .xfail ( reason = "Second precision not supported" ) )
121
134
datetimes = {"a" : [datetime (2001 , 1 , 1 ), None , datetime (2001 , 1 , 3 )]}
122
135
df = nw .from_native (constructor (datetimes ))
123
136
result = df .select (
@@ -145,17 +158,17 @@ def test_timestamp_dates(
145
158
expected : list [int | None ],
146
159
) -> None :
147
160
if any (x in str (constructor ) for x in ("duckdb" , "pyspark" )):
148
- request .applymarker (pytest .mark .xfail )
149
- if any (
150
- x in str (constructor )
151
- for x in (
152
- "pandas_constructor" ,
153
- "pandas_nullable_constructor" ,
154
- "cudf" ,
155
- "modin_constructor" ,
161
+ request .applymarker (
162
+ pytest .mark .xfail (reason = "Backend timestamp conversion not yet implemented" )
156
163
)
157
- ):
158
- request .applymarker (pytest .mark .xfail )
164
+ unsupported_backends = (
165
+ "pandas_constructor" ,
166
+ "pandas_nullable_constructor" ,
167
+ "cudf" ,
168
+ "modin_constructor" ,
169
+ )
170
+ if any (x in str (constructor ) for x in unsupported_backends ):
171
+ pytest .skip ("Backend does not support date type" )
159
172
160
173
dates = {"a" : [datetime (2001 , 1 , 1 ), None , datetime (2001 , 1 , 3 )]}
161
174
if "dask" in str (constructor ):
@@ -172,9 +185,15 @@ def test_timestamp_invalid_date(
172
185
request : pytest .FixtureRequest , constructor : Constructor
173
186
) -> None :
174
187
if any (x in str (constructor ) for x in ("duckdb" , "pyspark" )):
175
- request .applymarker (pytest .mark .xfail )
188
+ request .applymarker (
189
+ pytest .mark .xfail (reason = "Backend timestamp conversion not yet implemented" )
190
+ )
176
191
if "polars" in str (constructor ):
177
- request .applymarker (pytest .mark .xfail )
192
+ request .applymarker (
193
+ pytest .mark .xfail (
194
+ reason = "Invalid date handling not yet implemented in Polars"
195
+ )
196
+ )
178
197
data_str = {"a" : ["x" , "y" , None ]}
179
198
data_num = {"a" : [1 , 2 , None ]}
180
199
df_str = nw .from_native (constructor (data_str ))
0 commit comments