summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoxiang Sun <daetalusun@gmail.com>2015-12-10 18:48:48 +0800
committerBoxiang Sun <daetalusun@gmail.com>2015-12-12 13:26:50 +0800
commit7747c3a88cb0cad5687093d1345efcb2743fc1d5 (patch)
tree283153c923bcb2c9db3da8037ff623cba535cfd9
parent6d323aea603c9c077d9c84db91bf7fb6fd1a34e9 (diff)
downloadnumpy-7747c3a88cb0cad5687093d1345efcb2743fc1d5.tar.gz
BUG: Fix thinko in assert_deprecated()
assert_deprecated() was recently reworked for stylistic changes (in 0aa32608 "STY: Minor style cleanups in tests and C code.") but made a thinko - `lst` is already a list of warnings, so we don't need to put that into [] braces when preparing assertion text. If we do the reporting breaks: In [1]: msg = "4 warnings found but 3 expected." In [2]: lst = ['CategoryA', 'CategoryB', 'CategoryC'] In [3]: n.join([msg] + [lst]) TypeError Traceback (most recent call last) ----> 1 n.join([msg] + [lst]) TypeError: sequence item 1: expected string, list found Fix it. Cc: Charles Harris <charlesr.harris@gmail.com>
-rw-r--r--numpy/core/tests/test_deprecations.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 8f7e55d91..bfbe27e1b 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -89,7 +89,7 @@ class _DeprecationTestCase(object):
if num is not None and num_found != num:
msg = "%i warnings found but %i expected." % (len(self.log), num)
lst = [w.category for w in self.log]
- raise AssertionError("\n".join([msg] + [lst]))
+ raise AssertionError("\n".join([msg] + lst))
with warnings.catch_warnings():
warnings.filterwarnings("error", message=self.message,
@@ -400,5 +400,18 @@ class TestNonCContiguousViewDeprecation(_DeprecationTestCase):
self.assert_deprecated(np.ones((2,2)).T.view, args=(np.int8,))
+class TestTestDeprecated(object):
+ def test_assert_deprecated(self):
+ test_case_instance = _DeprecationTestCase()
+ test_case_instance.setUp()
+ assert_raises(AssertionError,
+ test_case_instance.assert_deprecated,
+ lambda: None)
+
+ def foo():
+ warnings.warn("foo", category=DeprecationWarning)
+
+ test_case_instance.assert_deprecated(foo)
+
if __name__ == "__main__":
run_module_suite()