File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -413,6 +413,7 @@ def from_current(cls, exprinfo=None):
413
413
to the exception message/``__str__()``
414
414
"""
415
415
tup = sys .exc_info ()
416
+ assert tup [0 ] is not None , "no current exception"
416
417
_striptext = ""
417
418
if exprinfo is None and isinstance (tup [1 ], AssertionError ):
418
419
exprinfo = getattr (tup [1 ], "msg" , None )
Original file line number Diff line number Diff line change @@ -172,6 +172,10 @@ def test_bad_getsource(self):
172
172
exci = _pytest ._code .ExceptionInfo .from_current ()
173
173
assert exci .getrepr ()
174
174
175
+ def test_from_current_with_missing (self ):
176
+ with pytest .raises (AssertionError , match = "no current exception" ):
177
+ _pytest ._code .ExceptionInfo .from_current ()
178
+
175
179
176
180
class TestTracebackEntry (object ):
177
181
def test_getsource (self ):
You can’t perform that action at this time.
0 commit comments