From 7a5e851013c1ff9beb9a1e7404ec1def69c80e67 Mon Sep 17 00:00:00 2001 From: Edoardo Abati <29585319+EdAbati@users.noreply.github.com> Date: Wed, 15 Jan 2025 22:59:43 +0100 Subject: [PATCH] update tests --- tests/expr_and_series/name/keep_test.py | 3 ++- tests/expr_and_series/name/map_test.py | 3 ++- tests/expr_and_series/name/prefix_test.py | 3 ++- tests/expr_and_series/name/to_lowercase_test.py | 3 ++- tests/expr_and_series/name/to_uppercase_test.py | 3 ++- tests/group_by_test.py | 10 +++++++--- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/expr_and_series/name/keep_test.py b/tests/expr_and_series/name/keep_test.py index e382db733..54219dae6 100644 --- a/tests/expr_and_series/name/keep_test.py +++ b/tests/expr_and_series/name/keep_test.py @@ -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 @@ -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`.", ) ) diff --git a/tests/expr_and_series/name/map_test.py b/tests/expr_and_series/name/map_test.py index 276138ef9..d86a12fbe 100644 --- a/tests/expr_and_series/name/map_test.py +++ b/tests/expr_and_series/name/map_test.py @@ -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 @@ -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`.", ) ) diff --git a/tests/expr_and_series/name/prefix_test.py b/tests/expr_and_series/name/prefix_test.py index 934d1d664..0f6ff2f61 100644 --- a/tests/expr_and_series/name/prefix_test.py +++ b/tests/expr_and_series/name/prefix_test.py @@ -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 @@ -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`.", ) ) diff --git a/tests/expr_and_series/name/to_lowercase_test.py b/tests/expr_and_series/name/to_lowercase_test.py index 1b39fc726..191e72275 100644 --- a/tests/expr_and_series/name/to_lowercase_test.py +++ b/tests/expr_and_series/name/to_lowercase_test.py @@ -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 @@ -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`.", ) ) diff --git a/tests/expr_and_series/name/to_uppercase_test.py b/tests/expr_and_series/name/to_uppercase_test.py index e6703212d..b0e49c7d5 100644 --- a/tests/expr_and_series/name/to_uppercase_test.py +++ b/tests/expr_and_series/name/to_uppercase_test.py @@ -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 @@ -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`.", ) ) diff --git a/tests/group_by_test.py b/tests/group_by_test.py index 911cc473e..40acd142b 100644 --- a/tests/group_by_test.py +++ b/tests/group_by_test.py @@ -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 @@ -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()) @@ -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"):