summaryrefslogtreecommitdiff
path: root/numpy/testing
diff options
context:
space:
mode:
authorMaxwell Aladago <maxwell.aladago@gmail.com>2019-09-08 11:32:58 -0400
committerMaxwell Aladago <maxwell.aladago@gmail.com>2019-09-08 11:32:58 -0400
commit3e75bec894ad5ef231ed912fc9b943d3a4fc327f (patch)
treeaff7b59a7ff17b504f324206ec99589833481865 /numpy/testing
parentdf85cd664b36c34f314e23f629d1ad53458468f7 (diff)
downloadnumpy-3e75bec894ad5ef231ed912fc9b943d3a4fc327f.tar.gz
a separate test for scalars base on review comments
Diffstat (limited to 'numpy/testing')
-rw-r--r--numpy/testing/tests/test_utils.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index c1e9fd237..44f93a693 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -564,7 +564,8 @@ class TestAlmostEqual(_GenericTest):
assert_equal(msgs[4], 'Max absolute difference: 2')
assert_equal(msgs[5], 'Max relative difference: inf')
- # check the error message when x is scalar
+ def test_error_message_2(self):
+ """Check the message is formatted correctly when either x or y is a scalar."""
x = 2
y = np.ones(20)
with pytest.raises(AssertionError) as exc_info:
@@ -574,6 +575,15 @@ class TestAlmostEqual(_GenericTest):
assert_equal(msgs[4], 'Max absolute difference: 1.')
assert_equal(msgs[5], 'Max relative difference: 1.')
+ y = 2
+ x = np.ones(20)
+ with pytest.raises(AssertionError) as exc_info:
+ self._assert_func(x, y)
+ msgs = str(exc_info.value).split('\n')
+ assert_equal(msgs[3], 'Mismatched elements: 20 / 20 (100%)')
+ assert_equal(msgs[4], 'Max absolute difference: 1.')
+ assert_equal(msgs[5], 'Max relative difference: 0.5')
+
def test_subclass_that_cannot_be_bool(self):
# While we cannot guarantee testing functions will always work for
# subclasses, the tests should ideally rely only on subclasses having