Skip to content

Commit 4bfd044

Browse files
committed
test(python): Improve coverage with extra predicate cases
Adapted from @alexander-beedie on [discord](https://discord.com/channels/908022250106667068/908022461751234570/1242428077955354684). I added 2 non-expression cases for the boolean masks.
1 parent 1c5ebd9 commit 4bfd044

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

py-polars/tests/unit/test_lazy.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,18 +211,26 @@ def test_filter_multiple_predicates() -> None:
211211
assert ldf.filter(predicate="==").select("description").collect().item() == "eq"
212212

213213

214-
def test_filter_seq_iterable() -> None:
214+
@pytest.mark.parametrize(
215+
"predicate",
216+
[
217+
[pl.lit(True)],
218+
iter([pl.lit(True)]),
219+
[True, True, True],
220+
iter([True, True, True]),
221+
(p for p in (pl.col("c") < 9,)),
222+
(p for p in (pl.col("a") > 0, pl.col("b") > 0)),
223+
],
224+
)
225+
def test_filter_seq_iterable_all_true(predicate: Any) -> None:
215226
ldf = pl.LazyFrame(
216227
{
217228
"a": [1, 1, 1],
218229
"b": [1, 1, 2],
219230
"c": [3, 1, 2],
220231
}
221232
)
222-
predicate = [pl.lit(True)]
223-
assert_frame_equal(
224-
ldf.filter(predicate).collect(), ldf.filter(iter(predicate)).collect()
225-
)
233+
assert_frame_equal(ldf, ldf.filter(predicate))
226234

227235

228236
def test_apply_custom_function() -> None:

0 commit comments

Comments
 (0)