kopia lustrzana https://github.com/micropython/micropython-lib
unittest: Make AssertRaisesContext store exception for later retrieval.
The statement "with assertRaises(errtype) as ctxt" checks the type of a raised exception, but did not store the exception into ctxt like unittest of CPython. The exception instance is usually used to check its message or other args.pull/551/head
rodzic
459e13921a
commit
9bc0b15f11
|
@ -24,6 +24,8 @@ class AssertRaisesContext:
|
|||
if exc_type is None:
|
||||
assert False, "%r not raised" % self.expected
|
||||
if issubclass(exc_type, self.expected):
|
||||
# store exception for later retrieval
|
||||
self.exception = exc_value
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue