What's the problem this feature will solve?
Currently, the AssertionError: Regex pattern did not match thrown on exit of a pytest.raises context when an exception was raised but the provided pattern was not matched is attached to the exception actually raised as its __context__ attribute implicitly. This causes the test failure report to incorrectly claim that 'During handling of the above exception, another exception occurred'.
Describe the solution you'd like
It should be attached to the __cause__ attribute instead, such that the connective would be 'The above exception was the direct cause of the following exception', which is more correct. Conceptually, that would mean doing something along the lines of the following:
raise AssertionError('Regex pattern did not match') from exc
where exc is the exception having occurred. However, I'm not sure where the logic is; I think it's in the matches method of the RaisesExc class.
What's the problem this feature will solve?
Currently, the
AssertionError: Regex pattern did not matchthrown on exit of apytest.raisescontext when an exception was raised but the provided pattern was not matched is attached to the exception actually raised as its__context__attribute implicitly. This causes the test failure report to incorrectly claim that 'During handling of the above exception, another exception occurred'.Describe the solution you'd like
It should be attached to the
__cause__attribute instead, such that the connective would be 'The above exception was the direct cause of the following exception', which is more correct. Conceptually, that would mean doing something along the lines of the following:where
excis the exception having occurred. However, I'm not sure where the logic is; I think it's in thematchesmethod of theRaisesExcclass.