mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
tests: CallException relaced with AssertionException in response validation
Generic exceptions are evil. When throwing a CallException in the request check you can't distinguish in the tests if it is an Exception that occured in during the execution (that's CallException) or during some tests (that used to be CallException as well).
This commit is contained in:
parent
bc036bc857
commit
d6f0c54d3e
@ -107,6 +107,11 @@ class CallException(Exception):
|
||||
self.args = [code, message]
|
||||
|
||||
|
||||
class AssertionException(Exception):
|
||||
def __init__(self, code, message):
|
||||
self.args = [code, message]
|
||||
|
||||
|
||||
class PinException(CallException):
|
||||
pass
|
||||
|
||||
@ -405,19 +410,19 @@ class DebugLinkMixin(object):
|
||||
try:
|
||||
expected = self.expected_responses.pop(0)
|
||||
except IndexError:
|
||||
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||
"Got %s, but no message has been expected" % pprint(msg))
|
||||
raise AssertionException(proto.FailureType.UnexpectedMessage,
|
||||
"Got %s, but no message has been expected" % pprint(msg))
|
||||
|
||||
if msg.__class__ != expected.__class__:
|
||||
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||
raise AssertionException(proto.FailureType.UnexpectedMessage,
|
||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||
|
||||
for field, value in expected.__dict__.items():
|
||||
if value is None or value == []:
|
||||
continue
|
||||
if getattr(msg, field) != value:
|
||||
raise CallException(proto.FailureType.UnexpectedMessage,
|
||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||
raise AssertionException(proto.FailureType.UnexpectedMessage,
|
||||
"Expected %s, got %s" % (pprint(expected), pprint(msg)))
|
||||
|
||||
def callback_ButtonRequest(self, msg):
|
||||
log("ButtonRequest code: " + get_buttonrequest_value(msg.code))
|
||||
|
Loading…
Reference in New Issue
Block a user