Skip to content

Commit

Permalink
Merge pull request #5506 from asottile/fix_no_terminal
Browse files Browse the repository at this point in the history
Fix crash when discovery fails while using `-p no:terminal`
  • Loading branch information
asottile committed Jun 27, 2019
2 parents 65fbdf2 + 4e723d6 commit f7bfbb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
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

0 comments on commit f7bfbb5

Please sign in to comment.