mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 07:20:56 +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:
parent
da89a17ce5
commit
a9faa4d4ab
@ -119,11 +119,12 @@ class TestCase:
|
|||||||
return AssertRaisesContext(exc)
|
return AssertRaisesContext(exc)
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
func(*args, **kwargs)
|
||||||
ensure(False, "%r not raised" % exc)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if isinstance(e, exc):
|
if isinstance(e, exc):
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
else:
|
||||||
|
ensure(False, "%r not raised" % exc)
|
||||||
|
|
||||||
def assertListEqual(self, x, y, msg=''):
|
def assertListEqual(self, x, y, msg=''):
|
||||||
if len(x) != len(y):
|
if len(x) != len(y):
|
||||||
|
Loading…
Reference in New Issue
Block a user