Skip to content

Commit fe6f0ff

Browse files
don't run tests to pyspark[connect]
1 parent a123a85 commit fe6f0ff

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

tests/expr_and_series/map_batches_test.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,25 @@
1919
from narwhals.dtypes import DType
2020

2121

22-
def xfail_not_implemented(constructor: Constructor) -> None:
22+
def xfail_not_implemented(
23+
constructor: Constructor, request: pytest.FixtureRequest
24+
) -> None:
2325
"""XFAIL if the constructor doesn't support map_batches."""
24-
if any(x in str(constructor) for x in ("dask", "duckdb", "ibis", "sqlframe")):
26+
constructor_id = str(request.node.callspec.id)
27+
print(constructor_id)
28+
if any(x in str(constructor) for x in ("dask", "duckdb", "ibis", "sqlframe")) or (
29+
constructor_id == "pyspark[connect]"
30+
):
2531
pytest.xfail("constructor doesn't support map_batches")
2632

2733

2834
data = {"a": [1, 2, 3], "b": [4, 5, 6], "z": [7.0, 8.0, 9.0]}
2935

3036

31-
def test_map_batches_expr_compliant(constructor: Constructor) -> None:
32-
xfail_not_implemented(constructor)
37+
def test_map_batches_expr_compliant(
38+
constructor: Constructor, request: pytest.FixtureRequest
39+
) -> None:
40+
xfail_not_implemented(constructor, request)
3341
df = nw.from_native(constructor(data))
3442
expected = df.select(nw.col("a", "b").map_batches(lambda s: s + 1).name.suffix("1"))
3543
assert_equal_data(expected, {"a1": [2, 3, 4], "b1": [5, 6, 7]})
@@ -67,8 +75,10 @@ def test_map_batches_expr_numpy_scalar(constructor_eager: ConstructorEager) -> N
6775
assert_equal_data(expected, {"a": [2], "b": [2], "z": [2]})
6876

6977

70-
def test_map_batches_expr_numpy_array(constructor: Constructor) -> None:
71-
xfail_not_implemented(constructor)
78+
def test_map_batches_expr_numpy_array(
79+
constructor: Constructor, request: pytest.FixtureRequest
80+
) -> None:
81+
xfail_not_implemented(constructor, request)
7282
df = nw.from_native(constructor(data))
7383
expected = df.select(
7484
nw.col("a")
@@ -78,8 +88,10 @@ def test_map_batches_expr_numpy_array(constructor: Constructor) -> None:
7888
assert_equal_data(expected, {"a": [9.0]})
7989

8090

81-
def test_map_batches_expr_names(constructor: Constructor) -> None:
82-
xfail_not_implemented(constructor)
91+
def test_map_batches_expr_names(
92+
constructor: Constructor, request: pytest.FixtureRequest
93+
) -> None:
94+
xfail_not_implemented(constructor, request)
8395
df = nw.from_native(constructor(data))
8496
expected = nw.from_native(df.select(nw.all().map_batches(lambda x: x.to_numpy())))
8597
assert_equal_data(expected, {"a": [1, 2, 3], "b": [4, 5, 6], "z": [7.0, 8.0, 9.0]})
@@ -103,8 +115,11 @@ def test_map_batches_exception(
103115
df.select(nw.all().map_batches(lambda s: s.to_numpy().argmax()))
104116

105117

106-
def test_map_batches_pyspark_scalar(constructor: Constructor) -> None: # pragma: no cover
107-
if "pyspark" not in str(constructor) or "sqlframe" in str(constructor):
118+
def test_map_batches_pyspark_scalar(
119+
constructor: Constructor, request: pytest.FixtureRequest
120+
) -> None: # pragma: no cover
121+
constructor_id = str(request.node.callspec.id)
122+
if constructor_id != "pyspark":
108123
pytest.xfail("Test only valid for pyspark")
109124
df = nw.from_native(constructor(data))
110125
expected = df.select(nw.col("a").map_batches(lambda _: 1.0))

0 commit comments

Comments
 (0)