Skip to content

Commit

Permalink
minor test improvement (match expected failure msg)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-beedie committed Oct 31, 2024
1 parent 6157f6e commit 9b3aaa0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions py-polars/tests/unit/operations/test_inequality_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,21 +449,30 @@ def test_ie_join_with_floats(

def test_raise_on_ambiguous_name() -> None:
df = pl.DataFrame({"id": [1, 2]})
with pytest.raises(pl.exceptions.InvalidOperationError):
with pytest.raises(
pl.exceptions.InvalidOperationError,
match="'join_where' predicate only refers to columns from a single table",
):
df.join_where(df, pl.col("id") >= pl.col("id"))


def test_raise_on_multiple_binary_comparisons() -> None:
df = pl.DataFrame({"id": [1, 2]})
with pytest.raises(pl.exceptions.InvalidOperationError):
with pytest.raises(
pl.exceptions.InvalidOperationError,
match="only one binary comparison allowed in each 'join_where' predicate, found: ",
):
df.join_where(
df, (pl.col("id") < pl.col("id")) & (pl.col("id") >= pl.col("id"))
df, (pl.col("id") < pl.col("id")) ^ (pl.col("id") >= pl.col("id"))
)


def test_raise_invalid_input_join_where() -> None:
df = pl.DataFrame({"id": [1, 2]})
with pytest.raises(pl.exceptions.InvalidOperationError):
with pytest.raises(
pl.exceptions.InvalidOperationError,
match="expected join keys/predicates",
):
df.join_where(df)


Expand Down Expand Up @@ -571,7 +580,10 @@ def test_raise_invalid_predicate() -> None:
left = pl.LazyFrame({"a": [1, 2]}).with_row_index()
right = pl.LazyFrame({"b": [1, 2]}).with_row_index()

with pytest.raises(pl.exceptions.InvalidOperationError):
with pytest.raises(
pl.exceptions.InvalidOperationError,
match="'join_where' predicate only refers to columns from a single table",
):
left.join_where(right, pl.col.index >= pl.col.a).collect()


Expand Down

0 comments on commit 9b3aaa0

Please sign in to comment.