summaryrefslogtreecommitdiff
path: root/numpy/matrixlib/tests/test_interaction.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/matrixlib/tests/test_interaction.py')
-rw-r--r--numpy/matrixlib/tests/test_interaction.py27
1 files changed, 10 insertions, 17 deletions
diff --git a/numpy/matrixlib/tests/test_interaction.py b/numpy/matrixlib/tests/test_interaction.py
index 608416ed7..5154bd621 100644
--- a/numpy/matrixlib/tests/test_interaction.py
+++ b/numpy/matrixlib/tests/test_interaction.py
@@ -324,24 +324,17 @@ class TestConcatenatorMatrix:
def test_array_equal_error_message_matrix():
# 2018-04-29: moved here from testing.tests.test_utils.
- try:
+ with pytest.raises(AssertionError) as exc_info:
assert_equal(np.array([1, 2]), np.matrix([1, 2]))
- except AssertionError as e:
- msg = str(e)
- msg2 = msg.replace("shapes (2L,), (1L, 2L)", "shapes (2,), (1, 2)")
- msg_reference = textwrap.dedent("""\
-
- Arrays are not equal
-
- (shapes (2,), (1, 2) mismatch)
- x: array([1, 2])
- y: matrix([[1, 2]])""")
- try:
- assert_equal(msg, msg_reference)
- except AssertionError:
- assert_equal(msg2, msg_reference)
- else:
- raise AssertionError("Did not raise")
+ msg = str(exc_info.value)
+ msg_reference = textwrap.dedent("""\
+
+ Arrays are not equal
+
+ (shapes (2,), (1, 2) mismatch)
+ x: array([1, 2])
+ y: matrix([[1, 2]])""")
+ assert_equal(msg, msg_reference)
def test_array_almost_equal_matrix():