core/tests: fix inline variant of assertRaises

otherwise code like the following would fail:

>>> self.assertRaises(AssertionError, ensure, False)

because the AssertionError raised internally by `ensure` would be
conflated with the AssertionError raised by the tested function
release/2020-04
matejcik 4 years ago committed by Tomas Susanka
parent da89a17ce5
commit a9faa4d4ab

@ -119,11 +119,12 @@ class TestCase:
return AssertRaisesContext(exc)
try:
func(*args, **kwargs)
ensure(False, "%r not raised" % exc)
except Exception as e:
if isinstance(e, exc):
return
raise
else:
ensure(False, "%r not raised" % exc)
def assertListEqual(self, x, y, msg=''):
if len(x) != len(y):

Loading…
Cancel
Save