File tree 4 files changed +11
-0
lines changed
4 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ Edison Gustavo Muenz
128
128
Edoardo Batini
129
129
Edson Tadeu M. Manoel
130
130
Eduardo Schettino
131
+ Edward Haigh
131
132
Eero Vaher
132
133
Eli Boyarski
133
134
Elizaveta Shashkova
Original file line number Diff line number Diff line change
1
+ Added support for :data: `sys.last_exc ` for post-mortem debugging on Python>=3.12.
Original file line number Diff line number Diff line change @@ -164,6 +164,8 @@ def pytest_runtest_call(item: Item) -> None:
164
164
del sys .last_type
165
165
del sys .last_value
166
166
del sys .last_traceback
167
+ if sys .version_info >= (3 , 12 , 0 ):
168
+ del sys .last_exc # type: ignore[attr-defined]
167
169
except AttributeError :
168
170
pass
169
171
try :
@@ -172,6 +174,8 @@ def pytest_runtest_call(item: Item) -> None:
172
174
# Store trace info to allow postmortem debugging
173
175
sys .last_type = type (e )
174
176
sys .last_value = e
177
+ if sys .version_info >= (3 , 12 , 0 ):
178
+ sys .last_exc = e # type: ignore[attr-defined]
175
179
assert e .__traceback__ is not None
176
180
# Skip *this* frame
177
181
sys .last_traceback = e .__traceback__ .tb_next
Original file line number Diff line number Diff line change @@ -926,6 +926,9 @@ def runtest(self):
926
926
# Check that exception info is stored on sys
927
927
assert sys .last_type is IndexError
928
928
assert isinstance (sys .last_value , IndexError )
929
+ if sys .version_info >= (3 , 12 , 0 ):
930
+ assert isinstance (sys .last_exc , IndexError ) # type: ignore[attr-defined]
931
+
929
932
assert sys .last_value .args [0 ] == "TEST"
930
933
assert sys .last_traceback
931
934
@@ -934,6 +937,8 @@ def runtest(self):
934
937
runner .pytest_runtest_call (ItemMightRaise ()) # type: ignore[arg-type]
935
938
assert not hasattr (sys , "last_type" )
936
939
assert not hasattr (sys , "last_value" )
940
+ if sys .version_info >= (3 , 12 , 0 ):
941
+ assert not hasattr (sys , "last_exc" )
937
942
assert not hasattr (sys , "last_traceback" )
938
943
939
944
You can’t perform that action at this time.
0 commit comments