1515from .reports import CollectReport
1616from .reports import TestReport
1717from _pytest ._code .code import ExceptionInfo
18+ from _pytest ._code .code import ExceptionRepr
1819from _pytest .compat import TYPE_CHECKING
20+ from _pytest .nodes import Collector
1921from _pytest .nodes import Node
2022from _pytest .outcomes import Exit
2123from _pytest .outcomes import Skipped
@@ -251,7 +253,7 @@ def pytest_runtest_makereport(item, call):
251253 return TestReport .from_item_and_call (item , call )
252254
253255
254- def pytest_make_collect_report (collector ) -> CollectReport :
256+ def pytest_make_collect_report (collector : Collector ) -> CollectReport :
255257 call = CallInfo .from_call (lambda : list (collector .collect ()), "collect" )
256258 longrepr = None
257259 if not call .excinfo :
@@ -264,7 +266,10 @@ def pytest_make_collect_report(collector) -> CollectReport:
264266 skip_exceptions .append (unittest .SkipTest ) # type: ignore
265267 if call .excinfo .errisinstance (tuple (skip_exceptions )):
266268 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
268273 longrepr = (str (r .path ), r .lineno , r .message )
269274 else :
270275 outcome = "failed"
0 commit comments