Skip to content

Commit 752d23d

Browse files
Change a test
to use 'pytester.runpytest' instead of using testing/python/metafunc.py::TestMetafunc::Metafunc to see if coverage get fixed
1 parent 70ca754 commit 752d23d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

testing/python/metafunc.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,21 @@ def test_parametrize_twoargs(self) -> None:
986986
assert metafunc._calls[1].params == dict(x=3, y=4)
987987
assert metafunc._calls[1].id == "3-4"
988988

989-
def test_parametrize_with_duplicate_args(self) -> None:
990-
metafunc = self.Metafunc(lambda x: None)
991-
metafunc.parametrize("x", [0, 1])
992-
with pytest.raises(ValueError, match="duplicate 'x'"):
993-
metafunc.parametrize("x", [2, 3])
989+
def test_parametrize_with_duplicate_args(self, pytester: Pytester) -> None:
990+
pytester.makepyfile(
991+
"""
992+
import pytest
993+
def pytest_generate_tests(metafunc):
994+
metafunc.parametrize('x', [0, 1])
995+
metafunc.parametrize('x', [2, 3])
996+
997+
def test(x):
998+
pass
999+
"""
1000+
)
1001+
result = pytester.runpytest("--collect-only")
1002+
assert any(["duplicate 'x'" in line for line in result.outlines])
1003+
result.assert_outcomes(errors=1)
9941004

9951005
def test_parametrize_with_duplicate_values(self) -> None:
9961006
metafunc = self.Metafunc(lambda x, y: None)

0 commit comments

Comments
 (0)