Skip to content

Commit 0173952

Browse files
committed
Fix py3 xfail expression evaluation and parametrize strict
1 parent 767c28d commit 0173952

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

testing/python/metafunc.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,22 +1080,23 @@ def test_increment(n, expected):
10801080
reprec = testdir.inline_run()
10811081
reprec.assertoutcome(passed=2, skipped=1)
10821082

1083-
def test_xfail_passing_is_xpass(self, testdir):
1083+
@pytest.mark.parametrize('strict', [True, False])
1084+
def test_xfail_passing_is_xpass(self, testdir, strict):
10841085
s = """
10851086
import pytest
10861087
10871088
@pytest.mark.parametrize(("n", "expected"), [
10881089
(1, 2),
1089-
pytest.mark.xfail("sys.version > 0", reason="some bug")((2, 3)),
1090+
pytest.mark.xfail("sys.version_info.major > 0", reason="some bug", strict={strict})((2, 3)),
10901091
(3, 4),
10911092
])
10921093
def test_increment(n, expected):
10931094
assert n + 1 == expected
1094-
"""
1095+
""".format(strict=strict)
10951096
testdir.makepyfile(s)
10961097
reprec = testdir.inline_run()
1097-
# xpass is fail, obviously :)
1098-
reprec.assertoutcome(passed=2, failed=1)
1098+
passed, failed = (2, 1) if strict else (3, 0)
1099+
reprec.assertoutcome(passed=passed, failed=failed)
10991100

11001101
def test_parametrize_called_in_generate_tests(self, testdir):
11011102
s = """

0 commit comments

Comments
 (0)