Skip to content

Commit b85d98e

Browse files
authored
Merge pull request #5508 from asottile/backport_5506
[4.6] Fix crash when discovery fails while using `-p no:terminal`
2 parents 554bff8 + f4b1c11 commit b85d98e

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-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
@@ -329,7 +329,7 @@ def repr_failure(self, excinfo):
329329

330330
# Respect explicit tbstyle option, but default to "short"
331331
# (None._repr_failure_py defaults to "long" without "fulltrace" option).
332-
tbstyle = self.config.getoption("tbstyle")
332+
tbstyle = self.config.getoption("tbstyle", "auto")
333333
if tbstyle == "auto":
334334
tbstyle = "short"
335335

testing/test_config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from _pytest.config.findpaths import determine_setup
1616
from _pytest.config.findpaths import get_common_ancestor
1717
from _pytest.config.findpaths import getcfg
18+
from _pytest.main import EXIT_INTERRUPTED
1819
from _pytest.main import EXIT_NOTESTSCOLLECTED
1920
from _pytest.main import EXIT_OK
2021
from _pytest.main import EXIT_TESTSFAILED
@@ -752,10 +753,10 @@ def pytest_addoption(parser):
752753
**{
753754
"conftest": conftest_source,
754755
"subdir/conftest": conftest_source,
755-
"subdir/test_foo": """
756+
"subdir/test_foo": """\
756757
def test_foo(pytestconfig):
757758
assert pytestconfig.getini('foo') == 'subdir'
758-
""",
759+
""",
759760
}
760761
)
761762

@@ -788,6 +789,12 @@ def pytest_internalerror(self, excrepr):
788789
assert "ValueError" in err
789790

790791

792+
def test_no_terminal_discovery_error(testdir):
793+
testdir.makepyfile("raise TypeError('oops!')")
794+
result = testdir.runpytest("-p", "no:terminal", "--collect-only")
795+
assert result.ret == EXIT_INTERRUPTED
796+
797+
791798
def test_load_initial_conftest_last_ordering(testdir, _config_for_test):
792799
pm = _config_for_test.pluginmanager
793800

0 commit comments

Comments
 (0)