Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EdAbati committed Jan 15, 2025
1 parent 71cf84a commit 7a5e851
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/expr_and_series/name/keep_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import Constructor
from tests.utils import assert_equal_data

Expand Down Expand Up @@ -47,7 +48,7 @@ def test_keep_raise_anonymous(
does_not_raise()
if isinstance(df_raw, (pl.LazyFrame, pl.DataFrame))
else pytest.raises(
ValueError,
AnonymousExprError,
match="Anonymous expressions are not supported in `.name.keep`.",
)
)
Expand Down
3 changes: 2 additions & 1 deletion tests/expr_and_series/name/map_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import Constructor
from tests.utils import assert_equal_data

Expand Down Expand Up @@ -51,7 +52,7 @@ def test_map_raise_anonymous(
does_not_raise()
if isinstance(df_raw, (pl.LazyFrame, pl.DataFrame))
else pytest.raises(
ValueError,
AnonymousExprError,
match="Anonymous expressions are not supported in `.name.map`.",
)
)
Expand Down
3 changes: 2 additions & 1 deletion tests/expr_and_series/name/prefix_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import Constructor
from tests.utils import assert_equal_data

Expand Down Expand Up @@ -48,7 +49,7 @@ def test_prefix_raise_anonymous(
does_not_raise()
if isinstance(df_raw, (pl.LazyFrame, pl.DataFrame))
else pytest.raises(
ValueError,
AnonymousExprError,
match="Anonymous expressions are not supported in `.name.prefix`.",
)
)
Expand Down
3 changes: 2 additions & 1 deletion tests/expr_and_series/name/to_lowercase_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import Constructor
from tests.utils import assert_equal_data

Expand Down Expand Up @@ -47,7 +48,7 @@ def test_to_lowercase_raise_anonymous(
does_not_raise()
if isinstance(df_raw, (pl.LazyFrame, pl.DataFrame))
else pytest.raises(
ValueError,
AnonymousExprError,
match="Anonymous expressions are not supported in `.name.to_lowercase`.",
)
)
Expand Down
3 changes: 2 additions & 1 deletion tests/expr_and_series/name/to_uppercase_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import Constructor
from tests.utils import assert_equal_data

Expand Down Expand Up @@ -44,7 +45,7 @@ def test_to_uppercase_raise_anonymous(
does_not_raise()
if isinstance(df_raw, (pl.LazyFrame, pl.DataFrame))
else pytest.raises(
ValueError,
AnonymousExprError,
match="Anonymous expressions are not supported in `.name.to_uppercase`.",
)
)
Expand Down
10 changes: 7 additions & 3 deletions tests/group_by_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pytest

import narwhals.stable.v1 as nw
from narwhals.exceptions import AnonymousExprError
from tests.utils import PANDAS_VERSION
from tests.utils import PYARROW_VERSION
from tests.utils import Constructor
Expand Down Expand Up @@ -49,7 +50,8 @@ def test_invalid_group_by_dask() -> None:
nw.from_native(df_dask).group_by("a").agg(nw.col("b"))

with pytest.raises(
ValueError, match=r"Anonymous expressions are not supported in group_by\.agg"
AnonymousExprError,
match=r"Anonymous expressions are not supported in `group_by\.agg`",
):
nw.from_native(df_dask).group_by("a").agg(nw.all().mean())

Expand All @@ -60,11 +62,13 @@ def test_invalid_group_by() -> None:
with pytest.raises(ValueError, match="does your"):
df.group_by("a").agg(nw.col("b"))
with pytest.raises(
ValueError, match=r"Anonymous expressions are not supported in group_by\.agg"
AnonymousExprError,
match=r"Anonymous expressions are not supported in `group_by\.agg`",
):
df.group_by("a").agg(nw.all().mean())
with pytest.raises(
ValueError, match=r"Anonymous expressions are not supported in group_by\.agg"
AnonymousExprError,
match=r"Anonymous expressions are not supported in `group_by\.agg`",
):
nw.from_native(pa.table({"a": [1, 2, 3]})).group_by("a").agg(nw.all().mean())
with pytest.raises(ValueError, match=r"Non-trivial complex aggregation found"):
Expand Down

0 comments on commit 7a5e851

Please sign in to comment.