diff options
Diffstat (limited to 'numpy/testing')
-rw-r--r-- | numpy/testing/_private/utils.py | 3 | ||||
-rw-r--r-- | numpy/testing/tests/test_utils.py | 16 |
2 files changed, 5 insertions, 14 deletions
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py index 80a6fdd10..4a8f42e06 100644 --- a/numpy/testing/_private/utils.py +++ b/numpy/testing/_private/utils.py @@ -1342,9 +1342,6 @@ def assert_raises_regex(exception_class, expected_regexp, *args, **kwargs): Alternatively, can be used as a context manager like `assert_raises`. - Name of this function adheres to Python 3.2+ reference, but should work in - all versions down to 2.6. - Notes ----- .. versionadded:: 1.9.0 diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index bbc04124f..4026a7a14 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -211,7 +211,7 @@ class TestArrayEqual(_GenericTest): with pytest.raises(AssertionError): with np.errstate(all="raise"): np.testing.assert_array_equal( - np.array([1, 2, 3], np.float32), + np.array([1, 2, 3], np.float32), np.array([1, 1e-40, 3], np.float32)) @@ -1223,7 +1223,7 @@ class TestStringEqual: lambda: assert_string_equal("aaa", "a+b")) -def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): +def assert_warn_len_equal(mod, n_in_context, py37=None): try: mod_warns = mod.__warningregistry__ except AttributeError: @@ -1237,10 +1237,7 @@ def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): mod_warns = {} num_warns = len(mod_warns) - # Python 3.4 appears to clear any pre-existing warnings of the same type, - # when raising warnings inside a catch_warnings block. So, there is a - # warning generated by the tests within the context manager, but no - # previous warnings. + if 'version' in mod_warns: # Python 3 adds a 'version' entry to the registry, # do not count it. @@ -1252,9 +1249,7 @@ def assert_warn_len_equal(mod, n_in_context, py34=None, py37=None): if sys.version_info[:2] >= (3, 7): if py37 is not None: n_in_context = py37 - else: - if py34 is not None: - n_in_context = py34 + assert_equal(num_warns, n_in_context) def test_warn_len_equal_call_scenarios(): @@ -1317,12 +1312,11 @@ def test_clear_and_catch_warnings(): warnings.warn('Another warning') assert_warn_len_equal(my_mod, 1, py37=0) # Another warning, no module spec does add to warnings dict, except on - # Python 3.4 (see comments in `assert_warn_len_equal`) # Python 3.7 catch_warnings doesn't make an entry for 'ignore'. with clear_and_catch_warnings(): warnings.simplefilter('ignore') warnings.warn('Another warning') - assert_warn_len_equal(my_mod, 2, py34=1, py37=0) + assert_warn_len_equal(my_mod, 2, py37=0) def test_suppress_warnings_module(): |