fix bug: a false xfail expression would erranonously report XPASS on failures
--HG-- branch : trunk
This commit is contained in:
parent
a161a865c8
commit
09ba42a1bb
|
@ -120,18 +120,20 @@ def pytest_runtest_setup(item):
|
|||
def pytest_runtest_makereport(__multicall__, item, call):
|
||||
if call.when != "call":
|
||||
return
|
||||
if hasattr(item, 'obj'):
|
||||
expr, result = evalexpression(item, 'xfail')
|
||||
if result:
|
||||
rep = __multicall__.execute()
|
||||
if call.excinfo:
|
||||
rep.skipped = True
|
||||
rep.failed = rep.passed = False
|
||||
else:
|
||||
rep.skipped = rep.passed = False
|
||||
rep.failed = True
|
||||
rep.keywords['xfail'] = True # expr
|
||||
return rep
|
||||
expr, result = evalexpression(item, 'xfail')
|
||||
rep = __multicall__.execute()
|
||||
if result:
|
||||
if call.excinfo:
|
||||
rep.skipped = True
|
||||
rep.failed = rep.passed = False
|
||||
else:
|
||||
rep.skipped = rep.passed = False
|
||||
rep.failed = True
|
||||
rep.keywords['xfail'] = expr
|
||||
else:
|
||||
if 'xfail' in rep.keywords:
|
||||
del rep.keywords['xfail']
|
||||
return rep
|
||||
|
||||
# called by terminalreporter progress reporting
|
||||
def pytest_report_teststatus(report):
|
||||
|
|
|
@ -59,6 +59,20 @@ def test_xfail_at_module(testdir):
|
|||
])
|
||||
assert result.ret == 0
|
||||
|
||||
def test_xfail_evalfalse_but_fails(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import py
|
||||
@py.test.mark.xfail('False')
|
||||
def test_fail():
|
||||
assert 0
|
||||
""")
|
||||
result = testdir.runpytest(p, '--report=xfailed')
|
||||
extra = result.stdout.fnmatch_lines([
|
||||
"*test_xfail_evalfalse_but_fails*:4*",
|
||||
"*1 failed*"
|
||||
])
|
||||
assert result.ret == 1
|
||||
|
||||
def test_skipif_decorator(testdir):
|
||||
p = testdir.makepyfile("""
|
||||
import py
|
||||
|
|
Loading…
Reference in New Issue