diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2017-12-11 15:42:27 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-11 15:42:27 -0700 |
| commit | 7a8c6b476786c86deeb87ad90f8920130821e355 (patch) | |
| tree | 73c7e7e4daef00e5907c3ae7445fa9b87e1db8d6 /numpy | |
| parent | d0bdc76786553bc3c4b1688335b731590ea52a8d (diff) | |
| parent | b98e5984c2c74c61b5ee452ce7553640622b46e7 (diff) | |
| download | numpy-7a8c6b476786c86deeb87ad90f8920130821e355.tar.gz | |
Merge pull request #10193 from charris/fix-deprecation-warning
BUG: Fix bugs found by testing in release mode.
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/core/tests/test_multiarray.py | 23 | ||||
| -rw-r--r-- | numpy/testing/nose_tools/utils.py | 9 |
2 files changed, 14 insertions, 18 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 4575ac8e2..3bddfe2ae 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -7087,21 +7087,14 @@ class TestFormat(object): def test_1d_format(self): # until gh-5543, ensure that the behaviour matches what it used to be a = np.array([np.pi]) - - def ret_and_exc(f, *args, **kwargs): - try: - return f(*args, **kwargs), None - except Exception as e: - # exceptions don't compare equal, so return type and args - # which do - return None, (type(e), e.args) - - # Could switch on python version here, but all we care about is - # that the behaviour hasn't changed - assert_equal( - ret_and_exc(object.__format__, a, '30'), - ret_and_exc('{:30}'.format, a) - ) + if sys.version_info[:2] >= (3, 4): + assert_raises(TypeError, '{:30}'.format, a) + else: + with suppress_warnings() as sup: + sup.filter(PendingDeprecationWarning) + res = '{:30}'.format(a) + dst = object.__format__(a, '30') + assert_equal(res, dst) class TestCTypes(object): diff --git a/numpy/testing/nose_tools/utils.py b/numpy/testing/nose_tools/utils.py index 973e3bb4b..6c77e5e21 100644 --- a/numpy/testing/nose_tools/utils.py +++ b/numpy/testing/nose_tools/utils.py @@ -394,14 +394,17 @@ def assert_equal(actual, desired, err_msg='', verbose=True): isdesnat = isnat(desired) isactnat = isnat(actual) dtypes_match = array(desired).dtype.type == array(actual).dtype.type - if isdesnat and isactnat and dtypes_match: + if isdesnat and isactnat: # If both are NaT (and have the same dtype -- datetime or # timedelta) they are considered equal. - return + if dtypes_match: + return + else: + raise AssertionError(msg) + except (TypeError, ValueError, NotImplementedError): pass - try: # Explicitly use __eq__ for comparison, gh-2552 if not (desired == actual): |
