Raise unexpected exceptions with pytest.raises() using match=

This commit is contained in:
Florian Bruhin
2018-02-15 12:11:56 +01:00
parent 9849022eb2
commit 3cbf0c8ec0
4 changed files with 12 additions and 2 deletions

View File

@@ -617,6 +617,6 @@ class RaisesContext(object):
suppress_exception = issubclass(self.excinfo.type, self.expected_exception)
if sys.version_info[0] == 2 and suppress_exception:
sys.exc_clear()
if self.match_expr:
if self.match_expr and suppress_exception:
self.excinfo.match(self.match_expr)
return suppress_exception