also accept non-pytrace pytest.fail() call in setup/teardown methods
This commit is contained in:
parent
c36b20b137
commit
539f828cdd
|
@ -324,14 +324,14 @@ class FunctionMixin(PyobjMixin):
|
||||||
if line.strip().startswith('def'):
|
if line.strip().startswith('def'):
|
||||||
return FuncargLookupErrorRepr(fspath, lineno,
|
return FuncargLookupErrorRepr(fspath, lineno,
|
||||||
lines[:i+1], str(excinfo.value))
|
lines[:i+1], str(excinfo.value))
|
||||||
|
if excinfo.errisinstance(pytest.fail.Exception):
|
||||||
|
if not excinfo.value.pytrace:
|
||||||
|
return str(excinfo.value)
|
||||||
return super(FunctionMixin, self)._repr_failure_py(excinfo,
|
return super(FunctionMixin, self)._repr_failure_py(excinfo,
|
||||||
style=style)
|
style=style)
|
||||||
|
|
||||||
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"
|
||||||
if excinfo.errisinstance(pytest.fail.Exception):
|
|
||||||
if not excinfo.value.pytrace:
|
|
||||||
return str(excinfo.value)
|
|
||||||
return self._repr_failure_py(excinfo,
|
return self._repr_failure_py(excinfo,
|
||||||
style=self.config.option.tbstyle)
|
style=self.config.option.tbstyle)
|
||||||
|
|
||||||
|
|
|
@ -339,11 +339,15 @@ def test_pytest_fail_notrace(testdir):
|
||||||
import pytest
|
import pytest
|
||||||
def test_hello():
|
def test_hello():
|
||||||
pytest.fail("hello", pytrace=False)
|
pytest.fail("hello", pytrace=False)
|
||||||
|
def teardown_function(function):
|
||||||
|
pytest.fail("world", pytrace=False)
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest()
|
result = testdir.runpytest()
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
"hello"
|
"world",
|
||||||
|
"hello",
|
||||||
])
|
])
|
||||||
|
assert 'def teardown_function' not in result.stdout.str()
|
||||||
|
|
||||||
def test_exception_printing_skip():
|
def test_exception_printing_skip():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue