From c2b611b0e9a07f36d4ff75f23f862cd7da82b9ff Mon Sep 17 00:00:00 2001 From: Anatoly Myachev Date: Tue, 12 Mar 2024 12:18:46 +0100 Subject: [PATCH] FIX-#7054: Update exception message for 'shift' function Signed-off-by: Anatoly Myachev --- modin/pandas/series.py | 4 +++- modin/pandas/test/test_series.py | 2 +- modin/pandas/test/utils.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modin/pandas/series.py b/modin/pandas/series.py index d4eb8f6faef..98dcb96efbe 100644 --- a/modin/pandas/series.py +++ b/modin/pandas/series.py @@ -1409,7 +1409,9 @@ def shift( + f"{type(self).__name__}.shift" ) if axis == 1: - raise ValueError(f"No axis named {axis} for object type {type(self)}") + raise ValueError( + f"No axis named {axis} for object type {type(self).__name__}" + ) return super(type(self), self).shift( periods=periods, freq=freq, axis=axis, fill_value=fill_value ) diff --git a/modin/pandas/test/test_series.py b/modin/pandas/test/test_series.py index 5d6260cd276..ce4e0df8a10 100644 --- a/modin/pandas/test/test_series.py +++ b/modin/pandas/test/test_series.py @@ -3262,11 +3262,11 @@ def test_sum(data, skipna, numeric_only, min_count): @pytest.mark.parametrize("operation", ["sum", "shift"]) def test_sum_axis_1_except(operation): - # ValueError('No axis named 1 for object type Series') eval_general( *create_test_series(test_data["int_data"]), lambda df, *args, **kwargs: getattr(df, operation)(*args, **kwargs), axis=1, + raising_exceptions=ValueError("No axis named 1 for object type Series"), ) diff --git a/modin/pandas/test/utils.py b/modin/pandas/test/utils.py index 258e4af6b7d..2a2ad8662aa 100644 --- a/modin/pandas/test/utils.py +++ b/modin/pandas/test/utils.py @@ -904,7 +904,7 @@ def execute_callable(fn, inplace=False, md_kwargs={}, pd_kwargs={}): assert not isinstance( md_e, tuple(raising_exceptions) ), f"not acceptable exception type: {md_e}" - elif raising_exceptions and type(raising_exceptions) is type: + elif raising_exceptions and type(raising_exceptions) is not type: assert ( type(md_e) is type(raising_exceptions) and md_e.args == raising_exceptions.args