Merged in jurko/pytest/break_ExceptionInfo_reference_cycles (pull request #144)
break reference cycles caused by storing local reference to exception info
This commit is contained in:
commit
f984e94fca
|
@ -149,11 +149,10 @@ def assertrepr_compare(config, op, left, right):
|
||||||
if istext(left) and istext(right):
|
if istext(left) and istext(right):
|
||||||
explanation = _notin_text(left, right, verbose)
|
explanation = _notin_text(left, right, verbose)
|
||||||
except Exception:
|
except Exception:
|
||||||
excinfo = py.code.ExceptionInfo()
|
|
||||||
explanation = [
|
explanation = [
|
||||||
u('(pytest_assertion plugin: representation of details failed. '
|
u('(pytest_assertion plugin: representation of details failed. '
|
||||||
'Probably an object has a faulty __repr__.)'),
|
'Probably an object has a faulty __repr__.)'),
|
||||||
u(excinfo)]
|
u(py.code.ExceptionInfo())]
|
||||||
|
|
||||||
if not explanation:
|
if not explanation:
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -98,6 +98,7 @@ def wrap_session(config, doit):
|
||||||
if session._testsfailed:
|
if session._testsfailed:
|
||||||
session.exitstatus = EXIT_TESTSFAILED
|
session.exitstatus = EXIT_TESTSFAILED
|
||||||
finally:
|
finally:
|
||||||
|
excinfo = None # Explicitly break reference cycle.
|
||||||
session.startdir.chdir()
|
session.startdir.chdir()
|
||||||
if initstate >= 2:
|
if initstate >= 2:
|
||||||
config.hook.pytest_sessionfinish(
|
config.hook.pytest_sessionfinish(
|
||||||
|
|
|
@ -456,8 +456,8 @@ class Module(pytest.File, PyCollector):
|
||||||
try:
|
try:
|
||||||
mod = self.fspath.pyimport(ensuresyspath=True)
|
mod = self.fspath.pyimport(ensuresyspath=True)
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
excinfo = py.code.ExceptionInfo()
|
raise self.CollectError(
|
||||||
raise self.CollectError(excinfo.getrepr(style="short"))
|
py.code.ExceptionInfo().getrepr(style="short"))
|
||||||
except self.fspath.ImportMismatchError:
|
except self.fspath.ImportMismatchError:
|
||||||
e = sys.exc_info()[1]
|
e = sys.exc_info()[1]
|
||||||
raise self.CollectError(
|
raise self.CollectError(
|
||||||
|
|
Loading…
Reference in New Issue