Skip to content

Commit 00eaa83

Browse files
parametrize test
1 parent c0f7457 commit 00eaa83

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

tests/expr_and_series/map_batches_test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,20 @@ def test_map_batches_exception(
114114
df.select(nw.all().map_batches(lambda s: s.to_numpy().argmax()))
115115

116116

117+
@pytest.mark.parametrize(
118+
("value", "dtype", "expected"),
119+
[(1, None, [1.0] * 3), ("asd", nw.String(), ["asd"] * 3)],
120+
)
117121
def test_map_batches_pyspark_scalar(
118-
constructor: Constructor, request: pytest.FixtureRequest
122+
constructor: Constructor,
123+
request: pytest.FixtureRequest,
124+
value: Any,
125+
dtype: DType,
126+
expected: Any,
119127
) -> None: # pragma: no cover
120128
constructor_id = str(request.node.callspec.id)
121129
if constructor_id != "pyspark":
122130
pytest.xfail("Test only valid for pyspark")
123131
df = nw.from_native(constructor(data))
124-
expected = df.select(nw.col("a").map_batches(lambda _: 1.0))
125-
assert_equal_data(expected, {"a": [1.0] * 3})
126-
127-
expected = df.select(nw.col("a").map_batches(lambda _: "asd", nw.String()))
128-
assert_equal_data(expected, {"a": ["asd"] * 3})
132+
expected = df.select(nw.col("a").map_batches(lambda _: value, dtype))
133+
assert_equal_data(expected, {"a": expected})

0 commit comments

Comments
 (0)