Fix crash when discovery fails while using `-p no:terminal`

This commit is contained in:
Anthony Sottile 2019-06-27 10:24:29 -07:00
parent 65fbdf2568
commit 4e723d6750
3 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1 @@
Fix crash when discovery fails while using ``-p no:terminal``.

View File

@ -323,7 +323,7 @@ class Collector(Node):
# Respect explicit tbstyle option, but default to "short" # Respect explicit tbstyle option, but default to "short"
# (None._repr_failure_py defaults to "long" without "fulltrace" option). # (None._repr_failure_py defaults to "long" without "fulltrace" option).
tbstyle = self.config.getoption("tbstyle") tbstyle = self.config.getoption("tbstyle", "auto")
if tbstyle == "auto": if tbstyle == "auto":
tbstyle = "short" tbstyle = "short"

View File

@ -741,10 +741,10 @@ def test_config_in_subdirectory_colon_command_line_issue2148(testdir):
**{ **{
"conftest": conftest_source, "conftest": conftest_source,
"subdir/conftest": conftest_source, "subdir/conftest": conftest_source,
"subdir/test_foo": """ "subdir/test_foo": """\
def test_foo(pytestconfig): def test_foo(pytestconfig):
assert pytestconfig.getini('foo') == 'subdir' assert pytestconfig.getini('foo') == 'subdir'
""", """,
} }
) )
@ -777,6 +777,12 @@ def test_notify_exception(testdir, capfd):
assert "ValueError" in err 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): def test_load_initial_conftest_last_ordering(testdir, _config_for_test):
pm = _config_for_test.pluginmanager pm = _config_for_test.pluginmanager