summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-12-10 11:03:07 -0700
committerCharles Harris <charlesr.harris@gmail.com>2017-12-10 13:16:06 -0700
commit50cdfdde3eca726f56cdac5c221de96251092120 (patch)
tree86bc8c8f4b9409c5db214a3e1849fb1feae7252f /numpy
parent5c16f535e7515c2394b19cc6778ad9b5ae24d729 (diff)
downloadnumpy-50cdfdde3eca726f56cdac5c221de96251092120.tar.gz
BUG: Fix test_1d_format test.
The test failed for numpy installed in release mode as the PendingDeprecationWarning issued by `object.__format__(a, '30')` was no longer converted to an error. The fix here is to make the test Python version dependent and suppress the warning when needed.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_multiarray.py23
1 files changed, 8 insertions, 15 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index e54d67a0d..690828cc8 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -7086,21 +7086,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):