Skip to content

Commit 507a70f

Browse files
committed
Reroute assertRaisesRegexp to prevent Python3 deprecation undermining warnings tests.
1 parent 8dab554 commit 507a70f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/iris/tests/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,17 @@ def assertXMLElement(self, obj, reference_filename):
512512
def assertArrayEqual(self, a, b, err_msg=''):
513513
np.testing.assert_array_equal(a, b, err_msg=err_msg)
514514

515+
def assertRaisesRegexp(self, *args, **kwargs):
516+
"""
517+
Emulate the old :meth:`unittest.TestCase.assertRaisesRegexp`.
518+
519+
Because the original function is now deprecated in Python 3.
520+
Now calls :meth:`six.assertRaisesRegex()` (no final "p") instead.
521+
It is the same, except for providing an additional 'msg' argument.
522+
523+
"""
524+
return six.assertRaisesRegex(self, *args, **kwargs)
525+
515526
def _assertMaskedArray(self, assertion, a, b, strict, **kwargs):
516527
# Define helper function to extract unmasked values as a 1d
517528
# array.

0 commit comments

Comments
 (0)