Merge pull request #5138 from ikonst/notify_exception_without_terminal
Fix dependencies on 'terminal' plugin
This commit is contained in:
commit
e87d3d70e2
1
AUTHORS
1
AUTHORS
|
@ -105,6 +105,7 @@ Hugo van Kemenade
|
||||||
Hui Wang (coldnight)
|
Hui Wang (coldnight)
|
||||||
Ian Bicking
|
Ian Bicking
|
||||||
Ian Lesperance
|
Ian Lesperance
|
||||||
|
Ilya Konstantinov
|
||||||
Ionuț Turturică
|
Ionuț Turturică
|
||||||
Iwan Briquemont
|
Iwan Briquemont
|
||||||
Jaap Broekhuizen
|
Jaap Broekhuizen
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Eliminate core dependency on 'terminal' plugin.
|
|
@ -699,7 +699,7 @@ class Config(object):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def notify_exception(self, excinfo, option=None):
|
def notify_exception(self, excinfo, option=None):
|
||||||
if option and option.fulltrace:
|
if option and getattr(option, "fulltrace", False):
|
||||||
style = "long"
|
style = "long"
|
||||||
else:
|
else:
|
||||||
style = "native"
|
style = "native"
|
||||||
|
|
|
@ -248,7 +248,7 @@ class Node(object):
|
||||||
if excinfo.errisinstance(fm.FixtureLookupError):
|
if excinfo.errisinstance(fm.FixtureLookupError):
|
||||||
return excinfo.value.formatrepr()
|
return excinfo.value.formatrepr()
|
||||||
tbfilter = True
|
tbfilter = True
|
||||||
if self.config.option.fulltrace:
|
if self.config.getoption("fulltrace", False):
|
||||||
style = "long"
|
style = "long"
|
||||||
else:
|
else:
|
||||||
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
|
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
|
||||||
|
@ -260,12 +260,12 @@ class Node(object):
|
||||||
style = "long"
|
style = "long"
|
||||||
# XXX should excinfo.getrepr record all data and toterminal() process it?
|
# XXX should excinfo.getrepr record all data and toterminal() process it?
|
||||||
if style is None:
|
if style is None:
|
||||||
if self.config.option.tbstyle == "short":
|
if self.config.getoption("tbstyle", "auto") == "short":
|
||||||
style = "short"
|
style = "short"
|
||||||
else:
|
else:
|
||||||
style = "long"
|
style = "long"
|
||||||
|
|
||||||
if self.config.option.verbose > 1:
|
if self.config.getoption("verbose", 0) > 1:
|
||||||
truncate_locals = False
|
truncate_locals = False
|
||||||
else:
|
else:
|
||||||
truncate_locals = True
|
truncate_locals = True
|
||||||
|
@ -279,7 +279,7 @@ class Node(object):
|
||||||
return excinfo.getrepr(
|
return excinfo.getrepr(
|
||||||
funcargs=True,
|
funcargs=True,
|
||||||
abspath=abspath,
|
abspath=abspath,
|
||||||
showlocals=self.config.option.showlocals,
|
showlocals=self.config.getoption("showlocals", False),
|
||||||
style=style,
|
style=style,
|
||||||
tbfilter=tbfilter,
|
tbfilter=tbfilter,
|
||||||
truncate_locals=truncate_locals,
|
truncate_locals=truncate_locals,
|
||||||
|
|
|
@ -820,7 +820,7 @@ class FunctionMixin(PyobjMixin):
|
||||||
self.obj = self._getobj()
|
self.obj = self._getobj()
|
||||||
|
|
||||||
def _prunetraceback(self, excinfo):
|
def _prunetraceback(self, excinfo):
|
||||||
if hasattr(self, "_obj") and not self.config.option.fulltrace:
|
if hasattr(self, "_obj") and not self.config.getoption("fulltrace", False):
|
||||||
code = _pytest._code.Code(get_real_func(self.obj))
|
code = _pytest._code.Code(get_real_func(self.obj))
|
||||||
path, firstlineno = code.path, code.firstlineno
|
path, firstlineno = code.path, code.firstlineno
|
||||||
traceback = excinfo.traceback
|
traceback = excinfo.traceback
|
||||||
|
@ -835,14 +835,14 @@ class FunctionMixin(PyobjMixin):
|
||||||
excinfo.traceback = ntraceback.filter()
|
excinfo.traceback = ntraceback.filter()
|
||||||
# issue364: mark all but first and last frames to
|
# issue364: mark all but first and last frames to
|
||||||
# only show a single-line message for each frame
|
# only show a single-line message for each frame
|
||||||
if self.config.option.tbstyle == "auto":
|
if self.config.getoption("tbstyle", "auto") == "auto":
|
||||||
if len(excinfo.traceback) > 2:
|
if len(excinfo.traceback) > 2:
|
||||||
for entry in excinfo.traceback[1:-1]:
|
for entry in excinfo.traceback[1:-1]:
|
||||||
entry.set_repr_style("short")
|
entry.set_repr_style("short")
|
||||||
|
|
||||||
def repr_failure(self, excinfo, outerr=None):
|
def repr_failure(self, excinfo, outerr=None):
|
||||||
assert outerr is None, "XXX outerr usage is deprecated"
|
assert outerr is None, "XXX outerr usage is deprecated"
|
||||||
style = self.config.option.tbstyle
|
style = self.config.getoption("tbstyle", "auto")
|
||||||
if style == "auto":
|
if style == "auto":
|
||||||
style = "long"
|
style = "long"
|
||||||
return self._repr_failure_py(excinfo, style=style)
|
return self._repr_failure_py(excinfo, style=style)
|
||||||
|
|
|
@ -361,7 +361,7 @@ class TestReport(BaseReport):
|
||||||
longrepr = item.repr_failure(excinfo)
|
longrepr = item.repr_failure(excinfo)
|
||||||
else: # exception in setup or teardown
|
else: # exception in setup or teardown
|
||||||
longrepr = item._repr_failure_py(
|
longrepr = item._repr_failure_py(
|
||||||
excinfo, style=item.config.option.tbstyle
|
excinfo, style=item.config.getoption("tbstyle", "auto")
|
||||||
)
|
)
|
||||||
for rwhen, key, content in item._report_sections:
|
for rwhen, key, content in item._report_sections:
|
||||||
sections.append(("Captured %s %s" % (key, rwhen), content))
|
sections.append(("Captured %s %s" % (key, rwhen), content))
|
||||||
|
|
|
@ -770,7 +770,7 @@ def test_notify_exception(testdir, capfd):
|
||||||
config = testdir.parseconfig()
|
config = testdir.parseconfig()
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
raise ValueError(1)
|
raise ValueError(1)
|
||||||
config.notify_exception(excinfo)
|
config.notify_exception(excinfo, config.option)
|
||||||
out, err = capfd.readouterr()
|
out, err = capfd.readouterr()
|
||||||
assert "ValueError" in err
|
assert "ValueError" in err
|
||||||
|
|
||||||
|
@ -779,10 +779,17 @@ def test_notify_exception(testdir, capfd):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
config.pluginmanager.register(A())
|
config.pluginmanager.register(A())
|
||||||
config.notify_exception(excinfo)
|
config.notify_exception(excinfo, config.option)
|
||||||
out, err = capfd.readouterr()
|
out, err = capfd.readouterr()
|
||||||
assert not err
|
assert not err
|
||||||
|
|
||||||
|
config = testdir.parseconfig("-p", "no:terminal")
|
||||||
|
with pytest.raises(ValueError) as excinfo:
|
||||||
|
raise ValueError(1)
|
||||||
|
config.notify_exception(excinfo, config.option)
|
||||||
|
out, err = capfd.readouterr()
|
||||||
|
assert "ValueError" in err
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue