diff --git a/pandas/tests/indexes/interval/test_construction.py b/pandas/tests/indexes/interval/test_construction.py index 484a05800561d..7a54ad5c180a4 100644 --- a/pandas/tests/indexes/interval/test_construction.py +++ b/pandas/tests/indexes/interval/test_construction.py @@ -331,8 +331,7 @@ def test_constructor_errors(self, constructor): constructor(5) # not an interval - msg = ("type <(class|type) 'numpy.int64'> with value 0 " - "is not an interval") + msg = "type with value 0 is not an interval" with pytest.raises(TypeError, match=msg): constructor([0, 1]) diff --git a/pandas/tests/io/test_packers.py b/pandas/tests/io/test_packers.py index a0a5780bac207..a00efe949e2bb 100644 --- a/pandas/tests/io/test_packers.py +++ b/pandas/tests/io/test_packers.py @@ -153,8 +153,7 @@ class A: def __init__(self): self.read = 0 - msg = (r"Invalid file path or buffer object type: <(class|type)" - r" '{}'>") + msg = "Invalid file path or buffer object type: " with pytest.raises(ValueError, match=msg.format('NoneType')): read_msgpack(path_or_buf=None) with pytest.raises(ValueError, match=msg.format('dict')): diff --git a/pandas/tests/reshape/merge/test_merge.py b/pandas/tests/reshape/merge/test_merge.py index 5662377b98452..7d9d9402f1a45 100644 --- a/pandas/tests/reshape/merge/test_merge.py +++ b/pandas/tests/reshape/merge/test_merge.py @@ -182,13 +182,11 @@ def test_merge_misspecified(self): right_on=['key1', 'key2']) def test_index_and_on_parameters_confusion(self): - msg = ("right_index parameter must be of type bool, not" - r" <(class|type) 'list'>") + msg = "right_index parameter must be of type bool, not " with pytest.raises(ValueError, match=msg): merge(self.df, self.df2, how='left', left_index=False, right_index=['key1', 'key2']) - msg = ("left_index parameter must be of type bool, not " - r"<(class|type) 'list'>") + msg = "left_index parameter must be of type bool, not " with pytest.raises(ValueError, match=msg): merge(self.df, self.df2, how='left', left_index=['key1', 'key2'], right_index=False) diff --git a/pandas/tests/series/indexing/test_numeric.py b/pandas/tests/series/indexing/test_numeric.py index 5bbd7e055975f..480d185f18b8d 100644 --- a/pandas/tests/series/indexing/test_numeric.py +++ b/pandas/tests/series/indexing/test_numeric.py @@ -204,7 +204,7 @@ def test_setitem_float_labels(): def test_slice_float_get_set(test_data): msg = (r"cannot do slice indexing on with these indexers \[{key}\]" - r" of <(class|type) 'float'>") + r" of ") with pytest.raises(TypeError, match=msg.format(key=r"4\.0")): test_data.ts[4.0:10.0] diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index ef6dca8d2729d..e5eb7d19dc649 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -91,7 +91,7 @@ def test_argsort_stable(self): check_dtype=False) tm.assert_series_equal(qindexer, Series(qexpected), check_dtype=False) - msg = (r"ndarray Expected type <(class|type) 'numpy\.ndarray'>," + msg = (r"ndarray Expected type ," r" found instead") with pytest.raises(AssertionError, match=msg): tm.assert_numpy_array_equal(qindexer, mindexer) diff --git a/pandas/tests/tslibs/test_timedeltas.py b/pandas/tests/tslibs/test_timedeltas.py index b53ea76a6ce4d..65ae9d6ed90ec 100644 --- a/pandas/tests/tslibs/test_timedeltas.py +++ b/pandas/tests/tslibs/test_timedeltas.py @@ -24,5 +24,5 @@ def test_delta_to_nanoseconds(obj, expected): def test_delta_to_nanoseconds_error(): obj = np.array([123456789], dtype="m8[ns]") - with pytest.raises(TypeError, match="<(class|type) 'numpy.ndarray'>"): + with pytest.raises(TypeError, match=""): delta_to_nanoseconds(obj)