Skip to content

Commit f7bfbb5

Browse files
authored
Merge pull request #5506 from asottile/fix_no_terminal
Fix crash when discovery fails while using `-p no:terminal`
2 parents 65fbdf2 + 4e723d6 commit f7bfbb5

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

changelog/5505.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash when discovery fails while using ``-p no:terminal``.

src/_pytest/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def repr_failure(self, excinfo):
323323

324324
# Respect explicit tbstyle option, but default to "short"
325325
# (None._repr_failure_py defaults to "long" without "fulltrace" option).
326-
tbstyle = self.config.getoption("tbstyle")
326+
tbstyle = self.config.getoption("tbstyle", "auto")
327327
if tbstyle == "auto":
328328
tbstyle = "short"
329329

testing/test_config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,10 @@ def pytest_addoption(parser):
741741
**{
742742
"conftest": conftest_source,
743743
"subdir/conftest": conftest_source,
744-
"subdir/test_foo": """
744+
"subdir/test_foo": """\
745745
def test_foo(pytestconfig):
746746
assert pytestconfig.getini('foo') == 'subdir'
747-
""",
747+
""",
748748
}
749749
)
750750

@@ -777,6 +777,12 @@ def pytest_internalerror(self, excrepr):
777777
assert "ValueError" in err
778778

779779

780+
def test_no_terminal_discovery_error(testdir):
781+
testdir.makepyfile("raise TypeError('oops!')")
782+
result = testdir.runpytest("-p", "no:terminal", "--collect-only")
783+
assert result.ret == ExitCode.INTERRUPTED
784+
785+
780786
def test_load_initial_conftest_last_ordering(testdir, _config_for_test):
781787
pm = _config_for_test.pluginmanager
782788

0 commit comments

Comments
 (0)