Skip to content

Commit 09e9a01

Browse files
committed
typing: fix _TracebackStyle: add "line"
1 parent e98176c commit 09e9a01

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/_pytest/_code/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
from _pytest._code import Source
4343

44-
_TracebackStyle = Literal["long", "short", "no", "native"]
44+
_TracebackStyle = Literal["long", "short", "line", "no", "native"]
4545

4646

4747
class Code:

src/_pytest/runner.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
from .reports import CollectReport
1616
from .reports import TestReport
1717
from _pytest._code.code import ExceptionInfo
18+
from _pytest._code.code import ExceptionRepr
1819
from _pytest.compat import TYPE_CHECKING
20+
from _pytest.nodes import Collector
1921
from _pytest.nodes import Node
2022
from _pytest.outcomes import Exit
2123
from _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

Comments
 (0)