summaryrefslogtreecommitdiff
path: root/numpy/testing/tests/test_utils.py
diff options
context:
space:
mode:
authorYoshiki Vázquez Baeza <yoshiki.vazquezbaeza@colorado.edu>2014-03-25 23:53:15 -0600
committerYoshiki Vázquez Baeza <yoshiki.vazquezbaeza@colorado.edu>2014-03-25 23:53:15 -0600
commita11c16249451c552e70a5ff73406f95b50961aa5 (patch)
tree5f57a5feb5671d0c824b13b55433138636cd90eb /numpy/testing/tests/test_utils.py
parentb1dfdea4b7e1a1e52f933dfdc075030f4b9b34ee (diff)
downloadnumpy-a11c16249451c552e70a5ff73406f95b50961aa5.tar.gz
TST: Change tests to look at array formatting only
The tests were looking at the formatting of other elements in the string which is not relevant for the things testsed in this case. By looking only at the array formatting, we guarantee consistency across systems.
Diffstat (limited to 'numpy/testing/tests/test_utils.py')
-rw-r--r--numpy/testing/tests/test_utils.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index f9821f28d..aa0a2669f 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -288,22 +288,24 @@ class TestAlmostEqual(_GenericTest, unittest.TestCase):
y = np.array([1.00000000002, 2.00000000003, 3.00004])
# test with a different amount of decimal digits
- b = ('\nArrays are not almost equal to 12 decimals\n\n(mismatch '
- '100.0%)\n x: array([ 1.00000000001, 2.00000000002, 3.00003 '
+ # note that we only check for the formatting of the arrays themselves
+ b = ('x: array([ 1.00000000001, 2.00000000002, 3.00003 '
' ])\n y: array([ 1.00000000002, 2.00000000003, 3.00004 ])')
try:
self._assert_func(x, y, decimal=12)
except AssertionError as e:
- self.assertEqual(str(e), b)
+ # remove anything that's not the array string
+ self.assertEqual(str(e).split('%)\n ')[1], b)
# with the default value of decimal digits, only the 3rd element differs
- b = ('\nArrays are not almost equal to 7 decimals\n\n(mismatch '
- '33.3333333333%)\n x: array([ 1. , 2. , 3.00003])\n y: '
- 'array([ 1. , 2. , 3.00004])')
+ # note that we only check for the formatting of the arrays themselves
+ b = ('x: array([ 1. , 2. , 3.00003])\n y: array([ 1. , '
+ '2. , 3.00004])')
try:
self._assert_func(x, y)
except AssertionError as e:
- self.assertEqual(str(e), b)
+ # remove anything that's not the array string
+ self.assertEqual(str(e).split('%)\n ')[1], b)
class TestApproxEqual(unittest.TestCase):
def setUp(self):