Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/5505.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix crash when discovery fails while using ``-p no:terminal``.
2 changes: 1 addition & 1 deletion src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def repr_failure(self, excinfo):

# Respect explicit tbstyle option, but default to "short"
# (None._repr_failure_py defaults to "long" without "fulltrace" option).
tbstyle = self.config.getoption("tbstyle")
tbstyle = self.config.getoption("tbstyle", "auto")
if tbstyle == "auto":
tbstyle = "short"

Expand Down
10 changes: 8 additions & 2 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,10 +741,10 @@ def pytest_addoption(parser):
**{
"conftest": conftest_source,
"subdir/conftest": conftest_source,
"subdir/test_foo": """
"subdir/test_foo": """\
def test_foo(pytestconfig):
assert pytestconfig.getini('foo') == 'subdir'
""",
""",
}
)

Expand Down Expand Up @@ -777,6 +777,12 @@ def pytest_internalerror(self, excrepr):
assert "ValueError" in err


def test_no_terminal_discovery_error(testdir):
testdir.makepyfile("raise TypeError('oops!')")
result = testdir.runpytest("-p", "no:terminal", "--collect-only")
assert result.ret == ExitCode.INTERRUPTED


def test_load_initial_conftest_last_ordering(testdir, _config_for_test):
pm = _config_for_test.pluginmanager

Expand Down