Remove sys.last_traceback attribute using del instead of settin… (#6256)
Remove sys.last_traceback attribute using del instead of setting to None
This commit is contained in:
commit
f1ac0eeef0
1
AUTHORS
1
AUTHORS
|
@ -165,6 +165,7 @@ Marcelo Duarte Trevisani
|
||||||
Marcin Bachry
|
Marcin Bachry
|
||||||
Marco Gorelli
|
Marco Gorelli
|
||||||
Mark Abramowitz
|
Mark Abramowitz
|
||||||
|
Mark Dickinson
|
||||||
Markus Unterwaditzer
|
Markus Unterwaditzer
|
||||||
Martijn Faassen
|
Martijn Faassen
|
||||||
Martin Altmayer
|
Martin Altmayer
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
Clear the ``sys.last_traceback``, ``sys.last_type`` and ``sys.last_value``
|
||||||
|
attributes by deleting them instead of setting them to ``None``. This better
|
||||||
|
matches the behaviour of the Python standard library.
|
|
@ -121,7 +121,12 @@ def pytest_runtest_setup(item):
|
||||||
|
|
||||||
def pytest_runtest_call(item):
|
def pytest_runtest_call(item):
|
||||||
_update_current_test_var(item, "call")
|
_update_current_test_var(item, "call")
|
||||||
sys.last_type, sys.last_value, sys.last_traceback = (None, None, None)
|
try:
|
||||||
|
del sys.last_type
|
||||||
|
del sys.last_value
|
||||||
|
del sys.last_traceback
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
item.runtest()
|
item.runtest()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
|
@ -900,9 +900,9 @@ def test_store_except_info_on_error():
|
||||||
# The next run should clear the exception info stored by the previous run
|
# The next run should clear the exception info stored by the previous run
|
||||||
ItemMightRaise.raise_error = False
|
ItemMightRaise.raise_error = False
|
||||||
runner.pytest_runtest_call(ItemMightRaise())
|
runner.pytest_runtest_call(ItemMightRaise())
|
||||||
assert sys.last_type is None
|
assert not hasattr(sys, "last_type")
|
||||||
assert sys.last_value is None
|
assert not hasattr(sys, "last_value")
|
||||||
assert sys.last_traceback is None
|
assert not hasattr(sys, "last_traceback")
|
||||||
|
|
||||||
|
|
||||||
def test_current_test_env_var(testdir, monkeypatch):
|
def test_current_test_env_var(testdir, monkeypatch):
|
||||||
|
|
Loading…
Reference in New Issue