Skip to content

Commit ba91ed3

Browse files
VlekSeeminSyed
authored andcommitted
TST: Avoid bare pytest.raises in test_series.py (pandas-dev#32879)
1 parent 6940ca4 commit ba91ed3

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def _get_axis_name(cls, axis):
367367
return cls._AXIS_NAMES[axis]
368368
except KeyError:
369369
pass
370-
raise ValueError(f"No axis named {axis} for object type {cls}")
370+
raise ValueError(f"No axis named {axis} for object type {cls.__name__}")
371371

372372
def _get_axis(self, axis):
373373
name = self._get_axis_name(axis)

pandas/tests/dtypes/test_dtypes.py

-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ def test_basic(self, dtype):
479479

480480
def test_empty(self):
481481
dt = PeriodDtype()
482-
# https://github.com/pandas-dev/pandas/issues/27388
483482
msg = "object has no attribute 'freqstr'"
484483
with pytest.raises(AttributeError, match=msg):
485484
str(dt)

pandas/tests/frame/methods/test_to_period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ def test_frame_to_period(self):
3131
pts = df.to_period("M", axis=1)
3232
tm.assert_index_equal(pts.columns, exp.columns.asfreq("M"))
3333

34-
msg = "No axis named 2 for object type <class 'pandas.core.frame.DataFrame'>"
34+
msg = "No axis named 2 for object type DataFrame"
3535
with pytest.raises(ValueError, match=msg):
3636
df.to_period(axis=2)

pandas/tests/generic/test_series.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ def test_set_axis_name_mi(self, func):
5858

5959
def test_set_axis_name_raises(self):
6060
s = pd.Series([1])
61-
with pytest.raises(ValueError):
61+
msg = "No axis named 1 for object type Series"
62+
with pytest.raises(ValueError, match=msg):
6263
s._set_axis_name(name="a", axis=1)
6364

6465
def test_get_numeric_data_preserve_dtype(self):

0 commit comments

Comments
 (0)