1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-09 06:50:58 +00:00

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
This commit is contained in:
matejcik 2020-03-16 16:12:51 +01:00 committed by Tomas Susanka
parent da89a17ce5
commit a9faa4d4ab

View File

@ -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):