fix issue 176: raises(AssertionError) now catches builtin AssertionError as well

This commit is contained in:
Ronny Pfannschmidt
2012-08-19 13:45:26 +02:00
parent 0cca20bef9
commit 0e8cd9297a
3 changed files with 17 additions and 0 deletions

View File

@@ -777,6 +777,11 @@ def raises(ExpectedException, *args, **kwargs):
<ExceptionInfo ...>
"""
__tracebackhide__ = True
if ExpectedException is AssertionError:
# we want to catch a AssertionError
# replace our subclass with the builtin one
# see https://bitbucket.org/hpk42/pytest/issue/176/pytestraises
from exceptions import AssertionError as ExpectedException
if not args:
return RaisesContext(ExpectedException)