Skip to content

Commit d63ec65

Browse files
authored
test: use skip tests on old versions instead of xfailing, print slowest tests (#2375)
1 parent 939e450 commit d63ec65

20 files changed

+129
-158
lines changed

.github/workflows/pytest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
run: uv pip freeze
5959
- name: Run pytest
6060
run: |
61-
pytest tests --cov=narwhals --cov=tests --runslow --cov-fail-under=95 --constructors=pandas,pandas[nullable],pandas[pyarrow],pyarrow,modin[pyarrow],polars[eager],polars[lazy],dask,duckdb,sqlframe
61+
pytest tests --cov=narwhals --cov=tests --runslow --cov-fail-under=95 --constructors=pandas,pandas[nullable],pandas[pyarrow],pyarrow,modin[pyarrow],polars[eager],polars[lazy],dask,duckdb,sqlframe --durations=30
6262
6363
pytest-full-coverage:
6464
strategy:
@@ -94,7 +94,7 @@ jobs:
9494
- name: show-deps
9595
run: uv pip freeze
9696
- name: Run pytest
97-
run: pytest tests --cov=narwhals --cov=tests --cov-fail-under=100 --runslow --constructors=pandas,pandas[nullable],pandas[pyarrow],pyarrow,modin[pyarrow],polars[eager],polars[lazy],dask,duckdb,sqlframe
97+
run: pytest tests --cov=narwhals --cov=tests --cov-fail-under=100 --runslow --constructors=pandas,pandas[nullable],pandas[pyarrow],pyarrow,modin[pyarrow],polars[eager],polars[lazy],dask,duckdb,sqlframe --durations=30
9898
- name: Run doctests
9999
# reprs differ between versions, so we only run doctests on the latest Python
100100
if: matrix.python-version == '3.13'

.github/workflows/typing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
PY_COLORS: 1
1010

1111
jobs:
12-
mypy:
12+
typing:
1313
strategy:
1414
matrix:
1515
python-version: ["3.12"]

narwhals/_arrow/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,8 @@ def _hist_from_bins(bins: Sequence[int | float]): # type: ignore[no-untyped-def
10871087
bin_right = bins[1:]
10881088
return counts, bin_right
10891089

1090-
counts: Sequence[int | float] | np.typing.ArrayLike
1091-
bin_right: Sequence[int | float] | np.typing.ArrayLike
1090+
counts: Sequence[int | float | pa.Scalar[Any]] | np.typing.ArrayLike
1091+
bin_right: Sequence[int | float | pa.Scalar[Any]] | np.typing.ArrayLike
10921092

10931093
data_count = pc.sum(
10941094
pc.invert(pc.or_(pc.is_nan(self.native), pc.is_null(self.native))).cast(

tests/expr_and_series/all_horizontal_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,9 @@ def test_allh_all(constructor: Constructor) -> None:
5151
assert_equal_data(result, expected)
5252

5353

54-
def test_allh_nth(
55-
constructor: Constructor,
56-
request: pytest.FixtureRequest,
57-
) -> None:
54+
def test_allh_nth(constructor: Constructor) -> None:
5855
if "polars" in str(constructor) and POLARS_VERSION < (1, 0):
59-
request.applymarker(pytest.mark.xfail)
56+
pytest.skip()
6057
data = {
6158
"a": [False, False, True],
6259
"b": [False, True, True],

tests/expr_and_series/arithmetic_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_right_arithmetic_expr(
6969
request: pytest.FixtureRequest,
7070
) -> None:
7171
if "dask" in str(constructor) and DASK_VERSION < (2024, 10):
72-
request.applymarker(pytest.mark.xfail)
72+
pytest.skip()
7373
if attr == "__rmod__" and any(
7474
x in str(constructor) for x in ["pandas_pyarrow", "modin_pyarrow"]
7575
):

tests/expr_and_series/binary_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from tests.utils import assert_equal_data
99

1010

11-
def test_expr_binary(constructor: Constructor, request: pytest.FixtureRequest) -> None:
11+
def test_expr_binary(constructor: Constructor) -> None:
1212
if "dask" in str(constructor) and DASK_VERSION < (2024, 10):
13-
request.applymarker(pytest.mark.xfail)
13+
pytest.skip()
1414
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8.0, 9.0]}
1515
df_raw = constructor(data)
1616
result = nw.from_native(df_raw).with_columns(

tests/expr_and_series/cast_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_cast_struct(request: pytest.FixtureRequest, constructor: Constructor) -
272272
request.applymarker(pytest.mark.xfail)
273273

274274
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
275-
request.applymarker(pytest.mark.xfail)
275+
pytest.skip()
276276

277277
data = {
278278
"a": [
@@ -322,7 +322,7 @@ def test_raise_if_polars_dtype(constructor: Constructor) -> None:
322322

323323
def test_cast_time(request: pytest.FixtureRequest, constructor: Constructor) -> None:
324324
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
325-
request.applymarker(pytest.mark.xfail)
325+
pytest.skip()
326326

327327
if any(
328328
backend in str(constructor) for backend in ("dask", "pyspark", "modin", "cudf")
@@ -337,7 +337,7 @@ def test_cast_time(request: pytest.FixtureRequest, constructor: Constructor) ->
337337

338338
def test_cast_binary(request: pytest.FixtureRequest, constructor: Constructor) -> None:
339339
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
340-
request.applymarker(pytest.mark.xfail)
340+
pytest.skip()
341341

342342
if any(backend in str(constructor) for backend in ("cudf", "dask", "modin")):
343343
request.applymarker(pytest.mark.xfail)

tests/expr_and_series/cat/get_categories_test.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@
1111
data = {"a": ["one", "two", "two"]}
1212

1313

14-
def test_get_categories(
15-
request: pytest.FixtureRequest,
16-
constructor_eager: ConstructorEager,
17-
) -> None:
14+
def test_get_categories(constructor_eager: ConstructorEager) -> None:
1815
if "pyarrow_table" in str(constructor_eager) and PYARROW_VERSION < (15, 0, 0):
19-
request.applymarker(pytest.mark.xfail)
16+
pytest.skip()
2017

2118
df = nw.from_native(constructor_eager(data), eager_only=True)
2219
df = df.select(nw.col("a").cast(nw.Categorical))

tests/expr_and_series/list/len_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_len_expr(
2121
request.applymarker(pytest.mark.xfail)
2222

2323
if "pandas" in str(constructor) and PANDAS_VERSION < (2, 2):
24-
request.applymarker(pytest.mark.xfail)
24+
pytest.skip()
2525

2626
result = nw.from_native(constructor(data)).select(
2727
nw.col("a").cast(nw.List(nw.Int32())).list.len()
@@ -38,7 +38,7 @@ def test_len_series(
3838
request.applymarker(pytest.mark.xfail)
3939

4040
if "pandas" in str(constructor_eager) and PANDAS_VERSION < (2, 2):
41-
request.applymarker(pytest.mark.xfail)
41+
pytest.skip()
4242

4343
df = nw.from_native(constructor_eager(data), eager_only=True)
4444

tests/expr_and_series/nth_test.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ def test_nth(
2525
constructor: Constructor,
2626
idx: int | list[int],
2727
expected: dict[str, list[int]],
28-
request: pytest.FixtureRequest,
2928
) -> None:
3029
if "polars" in str(constructor) and POLARS_VERSION < (1, 0, 0):
31-
request.applymarker(pytest.mark.xfail)
30+
pytest.skip()
3231
df = nw.from_native(constructor(data))
3332
result = df.select(nw.nth(idx))
3433
assert_equal_data(result, expected)

0 commit comments

Comments
 (0)