15
15
from .reports import CollectReport
16
16
from .reports import TestReport
17
17
from _pytest ._code .code import ExceptionInfo
18
+ from _pytest ._code .code import ExceptionRepr
18
19
from _pytest .compat import TYPE_CHECKING
20
+ from _pytest .nodes import Collector
19
21
from _pytest .nodes import Node
20
22
from _pytest .outcomes import Exit
21
23
from _pytest .outcomes import Skipped
@@ -251,7 +253,7 @@ def pytest_runtest_makereport(item, call):
251
253
return TestReport .from_item_and_call (item , call )
252
254
253
255
254
- def pytest_make_collect_report (collector ) -> CollectReport :
256
+ def pytest_make_collect_report (collector : Collector ) -> CollectReport :
255
257
call = CallInfo .from_call (lambda : list (collector .collect ()), "collect" )
256
258
longrepr = None
257
259
if not call .excinfo :
@@ -264,7 +266,10 @@ def pytest_make_collect_report(collector) -> CollectReport:
264
266
skip_exceptions .append (unittest .SkipTest ) # type: ignore
265
267
if call .excinfo .errisinstance (tuple (skip_exceptions )):
266
268
outcome = "skipped"
267
- r = collector ._repr_failure_py (call .excinfo , "line" ).reprcrash
269
+ r_ = collector ._repr_failure_py (call .excinfo , "line" )
270
+ assert isinstance (r_ , ExceptionRepr ), r_
271
+ r = r_ .reprcrash
272
+ assert r
268
273
longrepr = (str (r .path ), r .lineno , r .message )
269
274
else :
270
275
outcome = "failed"
0 commit comments