add new parameters:
xfail(run=False) will not run expected-to-fail tests xfail(reason=True) will report the specified reason --HG-- branch : trunk
This commit is contained in:
@@ -159,6 +159,9 @@ def test_generic(testdir, LineMatcher):
|
||||
@py.test.mark.xfail
|
||||
def test_xfail():
|
||||
assert 0
|
||||
@py.test.mark.xfail(run=False)
|
||||
def test_xfail_norun():
|
||||
assert 0
|
||||
""")
|
||||
testdir.runpytest("--resultlog=result.log")
|
||||
lines = testdir.tmpdir.join("result.log").readlines(cr=0)
|
||||
@@ -167,5 +170,6 @@ def test_generic(testdir, LineMatcher):
|
||||
"F *:test_fail",
|
||||
"s *:test_skip",
|
||||
"x *:test_xfail",
|
||||
"x *:test_xfail_norun",
|
||||
])
|
||||
|
||||
|
||||
@@ -12,6 +12,30 @@ def test_xfail_not_report_default(testdir):
|
||||
"*1 expected failures*--report=xfailed*",
|
||||
])
|
||||
|
||||
def test_xfail_not_run(testdir):
|
||||
p = testdir.makepyfile(test_one="""
|
||||
import py
|
||||
@py.test.mark.xfail(run=False, reason="noway")
|
||||
def test_this():
|
||||
assert 0
|
||||
@py.test.mark.xfail("True", run=False, reason="noway")
|
||||
def test_this_true():
|
||||
assert 0
|
||||
@py.test.mark.xfail("False", run=True, reason="huh")
|
||||
def test_this_false():
|
||||
assert 1
|
||||
""")
|
||||
result = testdir.runpytest(p, '-v')
|
||||
result.stdout.fnmatch_lines([
|
||||
"*2 expected failures*--report=xfailed*",
|
||||
"*1 passed*",
|
||||
])
|
||||
result = testdir.runpytest(p, '--report=xfailed', )
|
||||
result.stdout.fnmatch_lines([
|
||||
"*test_one*test_this*not run*noway",
|
||||
"*test_one*test_this_true*not run*noway",
|
||||
])
|
||||
|
||||
def test_skip_not_report_default(testdir):
|
||||
p = testdir.makepyfile(test_one="""
|
||||
import py
|
||||
|
||||
Reference in New Issue
Block a user