Skip to content

Commit ea379e0

Browse files
committed
Fix test in test_junitxml and add one for strict
1 parent 55ec1d7 commit ea379e0

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

testing/test_junitxml.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,33 @@ def test_xpass():
325325
result, dom = runandparse(testdir)
326326
# assert result.ret
327327
node = dom.find_first_by_tag("testsuite")
328-
node.assert_attr(skips=1, tests=1)
328+
node.assert_attr(skips=0, tests=1)
329329
tnode = node.find_first_by_tag("testcase")
330330
tnode.assert_attr(
331331
file="test_xfailure_xpass.py",
332332
line="1",
333333
classname="test_xfailure_xpass",
334334
name="test_xpass")
335-
fnode = tnode.find_first_by_tag("skipped")
336-
fnode.assert_attr(message="xfail-marked test passes unexpectedly")
337-
# assert "ValueError" in fnode.toxml()
335+
336+
def test_xfailure_xpass_strict(self, testdir):
337+
testdir.makepyfile("""
338+
import pytest
339+
@pytest.mark.xfail(strict=True, reason="This needs to fail!")
340+
def test_xpass():
341+
pass
342+
""")
343+
result, dom = runandparse(testdir)
344+
# assert result.ret
345+
node = dom.find_first_by_tag("testsuite")
346+
node.assert_attr(skips=0, tests=1)
347+
tnode = node.find_first_by_tag("testcase")
348+
tnode.assert_attr(
349+
file="test_xfailure_xpass_strict.py",
350+
line="1",
351+
classname="test_xfailure_xpass_strict",
352+
name="test_xpass")
353+
fnode = tnode.find_first_by_tag("failure")
354+
fnode.assert_attr(message="[XPASS(strict)] This needs to fail!")
338355

339356
def test_collect_error(self, testdir):
340357
testdir.makepyfile("syntax error")

0 commit comments

Comments
 (0)