File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments