From f6ec875ad80d12dafb06be25291b03007cae962c Mon Sep 17 00:00:00 2001 From: moink Date: Wed, 30 Dec 2020 12:40:58 +0100 Subject: [PATCH] TST: GH30999 add msg to pytest.raises in simple cases where modules have 1 instance --- pandas/tests/dtypes/test_inference.py | 2 +- pandas/tests/libs/test_hashtable.py | 3 +-- pandas/tests/resample/test_resampler_grouper.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index ce9d5b1dca505..e1f339e360c77 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -131,7 +131,7 @@ def foo(): inference.is_list_like([]) foo() - with pytest.raises(RecursionError): + with tm.external_error_raised(RecursionError): foo() diff --git a/pandas/tests/libs/test_hashtable.py b/pandas/tests/libs/test_hashtable.py index a6fd421911d3e..84398b3e63d31 100644 --- a/pandas/tests/libs/test_hashtable.py +++ b/pandas/tests/libs/test_hashtable.py @@ -69,9 +69,8 @@ def test_get_set_contains_len(self, table_type, dtype): assert table.get_item(index + 1) == 41 assert index + 2 not in table - with pytest.raises(KeyError) as excinfo: + with pytest.raises(KeyError, match=str(index + 2)): table.get_item(index + 2) - assert str(index + 2) in str(excinfo.value) def test_map(self, table_type, dtype): # PyObjectHashTable has no map-method diff --git a/pandas/tests/resample/test_resampler_grouper.py b/pandas/tests/resample/test_resampler_grouper.py index da5bb0eb59f70..86955ac4e4d22 100644 --- a/pandas/tests/resample/test_resampler_grouper.py +++ b/pandas/tests/resample/test_resampler_grouper.py @@ -151,7 +151,7 @@ def test_groupby_with_origin(): count_ts = ts.groupby(simple_grouper).agg("count") count_ts = count_ts[middle:end] count_ts2 = ts2.groupby(simple_grouper).agg("count") - with pytest.raises(AssertionError): + with pytest.raises(AssertionError, match="Index are different"): tm.assert_index_equal(count_ts.index, count_ts2.index) # test origin on 1970-01-01 00:00:00