This commit is contained in:
Gleb Nikonorov 2022-06-28 16:09:21 +09:00 committed by GitHub
commit 04a2765a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix the crash that occurred when pytest was invoked with `-o empty_parameter_set_mark=xfail` + `--runxfail`

View File

@ -346,7 +346,7 @@ def reorder_items_atscope(
def get_direct_param_fixture_func(request):
return request.param
return request.param if hasattr(request, "param") else None
@attr.s(slots=True, auto_attribs=True)

View File

@ -680,6 +680,41 @@ class TestXFail:
result.stdout.fnmatch_lines(["*1 passed*"])
assert result.ret == 0
@pytest.mark.parametrize("strict", [True, False])
def test_runxfail_with_empty_parameter_set_mark_xfail(self, testdir, strict):
testdir.makeini(
"""
[pytest]
xfail_strict = %s
"""
% strict
)
p = testdir.makepyfile(
"""
import pytest
@pytest.mark.parametrize(
('a', 'b'),
# no cases defined yet
(
),
)
def test(a, b):
assert 1 == 1
"""
)
result = testdir.runpytest(
p, "--runxfail", "-o", "empty_parameter_set_mark=xfail"
)
result.stdout.fnmatch_lines(["*1 failed*" if strict else "*1 passed*"])
if strict:
result.stdout.fnmatch_lines(
["*XPASS(strict)] got empty parameter set ('a', 'b')*"]
)
assert result.ret == (1 if strict else 0)
@pytest.mark.parametrize("strict_val", ["true", "false"])
def test_strict_xfail_default_from_file(
self, pytester: Pytester, strict_val