From 0519914675764ff183521712e3a7d4e57da1d331 Mon Sep 17 00:00:00 2001 From: mzeitlin11 <37011898+mzeitlin11@users.noreply.github.com> Date: Tue, 22 Dec 2020 08:40:41 -0500 Subject: [PATCH] Bug: assert_produces_warning(None) not raising AssertionError with warning (#38626) --- pandas/_testing.py | 7 +++---- pandas/tests/arithmetic/test_timedelta64.py | 1 + pandas/tests/frame/test_arithmetic.py | 1 + pandas/tests/indexes/test_common.py | 1 + pandas/tests/io/parser/test_common.py | 1 + .../tests/util/test_assert_produces_warning.py | 17 +++++++++++++++++ 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pandas/_testing.py b/pandas/_testing.py index 2d74cc89b8063..cad95ca571258 100644 --- a/pandas/_testing.py +++ b/pandas/_testing.py @@ -2724,11 +2724,10 @@ class for all warnings. To check that no warning is returned, extra_warnings = [] for actual_warning in w: - if not expected_warning: - continue - expected_warning = cast(Type[Warning], expected_warning) - if issubclass(actual_warning.category, expected_warning): + if expected_warning and issubclass( + actual_warning.category, expected_warning + ): saw_warning = True if check_stacklevel and issubclass( diff --git a/pandas/tests/arithmetic/test_timedelta64.py b/pandas/tests/arithmetic/test_timedelta64.py index 092a3f0d4402f..110f55a49eea3 100644 --- a/pandas/tests/arithmetic/test_timedelta64.py +++ b/pandas/tests/arithmetic/test_timedelta64.py @@ -543,6 +543,7 @@ def test_tda_add_sub_index(self): expected = tdi - tdi tm.assert_index_equal(result, expected) + @pytest.mark.xfail(reason="GH38630", strict=False) def test_tda_add_dt64_object_array(self, box_with_array, tz_naive_fixture): # Result should be cast back to DatetimeArray box = box_with_array diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index e5ec3c5641bd2..e6d1cd5f47d8d 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -821,6 +821,7 @@ def test_frame_with_frame_reindex(self): (np.datetime64(20, "ns"), "