fix #4386 - restructure construction and partial state of ExceptionInfo

This commit is contained in:
Ronny Pfannschmidt
2018-11-22 12:20:14 +01:00
parent 6e85febf20
commit 88bf01a31e
12 changed files with 113 additions and 59 deletions

View File

@@ -684,13 +684,13 @@ def raises(expected_exception, *args, **kwargs):
# XXX didn't mean f_globals == f_locals something special?
# this is destroyed here ...
except expected_exception:
return _pytest._code.ExceptionInfo()
return _pytest._code.ExceptionInfo.from_current()
else:
func = args[0]
try:
func(*args[1:], **kwargs)
except expected_exception:
return _pytest._code.ExceptionInfo()
return _pytest._code.ExceptionInfo.from_current()
fail(message)
@@ -705,7 +705,7 @@ class RaisesContext(object):
self.excinfo = None
def __enter__(self):
self.excinfo = object.__new__(_pytest._code.ExceptionInfo)
self.excinfo = _pytest._code.ExceptionInfo.for_later()
return self.excinfo
def __exit__(self, *tp):