diff --git a/pandas/tests/arrays/categorical/test_api.py b/pandas/tests/arrays/categorical/test_api.py index 87b1bb88aeac3..391a5e7e69ffe 100644 --- a/pandas/tests/arrays/categorical/test_api.py +++ b/pandas/tests/arrays/categorical/test_api.py @@ -53,7 +53,7 @@ def test_set_ordered(self): assert not cat2.ordered # removed in 0.19.0 - msg = "can't set attribute" + msg = "can't set attribute|property .* of .* object has no setter" with pytest.raises(AttributeError, match=msg): cat.ordered = True with pytest.raises(AttributeError, match=msg): @@ -507,7 +507,8 @@ def test_codes_immutable(self): tm.assert_numpy_array_equal(c.codes, exp) # Assignments to codes should raise - with pytest.raises(AttributeError, match="can't set attribute"): + msg = "can't set attribute|property .* of .* object has no setter" + with pytest.raises(AttributeError, match=msg): c.codes = np.array([0, 1, 2, 0, 1], dtype="int8") # changes in the codes array should raise diff --git a/pandas/tests/indexes/multi/test_get_set.py b/pandas/tests/indexes/multi/test_get_set.py index aa0e91cecd4fc..0ac3f0d2905a0 100644 --- a/pandas/tests/indexes/multi/test_get_set.py +++ b/pandas/tests/indexes/multi/test_get_set.py @@ -139,7 +139,7 @@ def test_set_levels_codes_directly(idx): minor_codes = [(x + 1) % 1 for x in minor_codes] new_codes = [major_codes, minor_codes] - msg = "[Cc]an't set attribute" + msg = "[Cc]an't set attribute|property .* of .* object has no setter" with pytest.raises(AttributeError, match=msg): idx.levels = new_levels with pytest.raises(AttributeError, match=msg): diff --git a/pandas/tests/indexes/period/test_freq_attr.py b/pandas/tests/indexes/period/test_freq_attr.py index 3bf3e700e5e72..7407effb22376 100644 --- a/pandas/tests/indexes/period/test_freq_attr.py +++ b/pandas/tests/indexes/period/test_freq_attr.py @@ -17,5 +17,6 @@ def test_freq_setter_deprecated(self): idx.freq # warning for setter - with pytest.raises(AttributeError, match="can't set attribute"): + msg = "can't set attribute|property .* of .* object has no setter" + with pytest.raises(AttributeError, match=msg): idx.freq = offsets.Day()