sematic
sematic copied to clipboard
Provide syntactic sugar for Exception layering matching
The Exception layering scheme proposed in #264 will require rigorous and elaborate unit testing capabilities.
Currently we do have glimpse of the complexity needed to validate Exception handling. As an example:
with pytest.raises(ResolutionError, match="FAIL!") as exc_info:
future.resolve()
assert isinstance(exc_info.value.__context__, CalculatorError)
assert isinstance(exc_info.value.__context__.__context__, SomeException)
This patterns repeats several times through the codebase. There should be syntactic sugar that shortens this usage pattern, turning the above into:
with sematic.raises(ResolutionError, CalculatorError, SomeException, match="FAIL!"):
future.resolve()