summaryrefslogtreecommitdiff
path: root/numpy/testing/tests
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2015-11-14 14:28:25 +0200
committerPauli Virtanen <pav@iki.fi>2015-11-14 14:28:25 +0200
commiteadc135a5f2ab577748188770af66feafe87859d (patch)
tree252fdf346b3cd5c211a2209e3176cb515afb010f /numpy/testing/tests
parentf83d68bdac7bf0843f1601da25ac51f97983b1ef (diff)
downloadnumpy-eadc135a5f2ab577748188770af66feafe87859d.tar.gz
BUG: testing: fix a bug in assert_string_equal
Diffstat (limited to 'numpy/testing/tests')
-rw-r--r--numpy/testing/tests/test_utils.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index a31fce4af..13aeffe02 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -9,7 +9,8 @@ from numpy.testing import (
assert_array_almost_equal, build_err_msg, raises, assert_raises,
assert_warns, assert_no_warnings, assert_allclose, assert_approx_equal,
assert_array_almost_equal_nulp, assert_array_max_ulp,
- clear_and_catch_warnings, run_module_suite
+ clear_and_catch_warnings, run_module_suite,
+ assert_string_equal
)
import unittest
@@ -715,6 +716,22 @@ class TestULP(unittest.TestCase):
lambda: assert_array_max_ulp(nan, nzero,
maxulp=maxulp))
+class TestStringEqual(unittest.TestCase):
+ def test_simple(self):
+ assert_string_equal("hello", "hello")
+ assert_string_equal("hello\nmultiline", "hello\nmultiline")
+
+ try:
+ assert_string_equal("foo\nbar", "hello\nbar")
+ except AssertionError as exc:
+ assert_equal(str(exc), "Differences in strings:\n- foo\n+ hello")
+ else:
+ raise AssertionError("exception not raised")
+
+ self.assertRaises(AssertionError,
+ lambda: assert_string_equal("foo", "hello"))
+
+
def assert_warn_len_equal(mod, n_in_context):
mod_warns = mod.__warningregistry__
# Python 3.4 appears to clear any pre-existing warnings of the same type,