From ac40c2ea38021ee57a8c6261cfc9b792bc51970b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Fri, 20 May 2022 20:45:54 -0700 Subject: MAINT: revert changes, so all tests pass for warning contexts --- numpy/testing/tests/test_utils.py | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'numpy/testing') diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index 6fa51454f..49eeecc8e 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -1310,11 +1310,12 @@ def test_clear_and_catch_warnings(): warnings.simplefilter('ignore') warnings.warn('Another warning') assert_warn_len_equal(my_mod, 2) - # Another warning, no module spec does add to warnings dict + + # Another warning, no module spec it clears up registry with clear_and_catch_warnings(): warnings.simplefilter('ignore') warnings.warn('Another warning') - assert_warn_len_equal(my_mod, 2) + assert_warn_len_equal(my_mod, 0) def test_suppress_warnings_module(): @@ -1356,15 +1357,11 @@ def test_suppress_warnings_module(): warnings.warn('Some warning') assert_warn_len_equal(my_mod, 0) - # Manually adding two warnings to the registry: - my_mod.__warningregistry__ = {'warning1': 1, - 'warning2': 2} - - # Without specified modules, don't clear warnings during context + # Without specified modules with suppress_warnings(): warnings.simplefilter('ignore') warnings.warn('Some warning') - assert_warn_len_equal(my_mod, 2) + assert_warn_len_equal(my_mod, 0) def test_suppress_warnings_type(): @@ -1388,15 +1385,11 @@ def test_suppress_warnings_type(): warnings.warn('Some warning') assert_warn_len_equal(my_mod, 0) - # Manually adding two warnings to the registry: - my_mod.__warningregistry__ = {'warning1': 1, - 'warning2': 2} - - # Without specified modules, don't clear warnings during context + # Without specified modules with suppress_warnings(): warnings.simplefilter('ignore') warnings.warn('Some warning') - assert_warn_len_equal(my_mod, 2) + assert_warn_len_equal(my_mod, 0) def test_suppress_warnings_decorate_no_record(): -- cgit v1.2.1