Skip to content

Commit 6d4a686

Browse files
committed
COMPAT/TST: add assertRaises and assertRaisesRegex to the base TestCase to avoid confusion
1 parent ad90f82 commit 6d4a686

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/util/testing.py

+8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ def assertNotIsInstance(self, obj, cls, msg=''):
156156
"%sExpected object to be of type %r, found %r instead" % (
157157
msg, cls, type(obj)))
158158

159+
def assertRaises(self, _exception, _callable=None, *args, **kwargs):
160+
""" compat with 2.6; assert that an exception is raised """
161+
assertRaises(_exception, _callable, *args, **kwargs)
162+
163+
def assertRaisesRegexp(self, _exception, _regexp, _callable=None, *args, **kwargs):
164+
""" Port of assertRaisesRegexp from unittest in Python 2.7 - used in with statement """
165+
assertRaisesRegexp(_exception, _regexp, _callable, *args, **kwargs)
166+
159167
# NOTE: don't pass an NDFrame or index to this function - may not handle it
160168
# well.
161169
assert_almost_equal = _testing.assert_almost_equal

0 commit comments

Comments
 (0)