File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -275,12 +275,14 @@ def _test_pytest_function(pyfuncitem):
275275 _pdb = pytestPDB ._init_pdb ("runcall" )
276276 testfunction = pyfuncitem .obj
277277 pyfuncitem .obj = _pdb .runcall
278- if "func" in pyfuncitem ._fixtureinfo . argnames : # pragma: no branch
278+ if "func" in pyfuncitem .funcargs : # pragma: no branch
279279 raise ValueError ("--trace can't be used with a fixture named func!" )
280280 pyfuncitem .funcargs ["func" ] = testfunction
281- new_list = list (pyfuncitem ._fixtureinfo .argnames )
282- new_list .append ("func" )
283- pyfuncitem ._fixtureinfo .argnames = tuple (new_list )
281+ if "func" not in pyfuncitem ._fixtureinfo .argnames :
282+ # if using e.g. parametrize the _fixtureinfo is shared
283+ new_list = list (pyfuncitem ._fixtureinfo .argnames )
284+ new_list .append ("func" )
285+ pyfuncitem ._fixtureinfo .argnames = tuple (new_list )
284286
285287
286288def _enter_pdb (node , excinfo , rep ):
Original file line number Diff line number Diff line change @@ -1025,6 +1025,30 @@ def test_3():
10251025 assert "Exit: Quitting debugger" not in child .before .decode ("utf8" )
10261026 TestPDB .flush (child )
10271027
1028+ def test_trace_with_parametrize (self , testdir ):
1029+ p1 = testdir .makepyfile (
1030+ """
1031+ import pytest
1032+
1033+ @pytest.mark.parametrize('x', [1,2])
1034+ def test_1(x):
1035+ assert True
1036+ """
1037+ )
1038+ child = testdir .spawn_pytest ("--trace " + str (p1 ))
1039+ child .expect ("test_1" )
1040+ child .expect ("Pdb" )
1041+ child .sendline ("c" )
1042+ child .expect ("test_1" )
1043+ child .expect ("Pdb" )
1044+ child .sendline ("c" )
1045+ rest = child .read ().decode ("utf8" )
1046+ assert "2 passed in" in rest
1047+ assert "reading from stdin while output" not in rest
1048+ # Only printed once - not on stderr.
1049+ assert "Exit: Quitting debugger" not in child .before .decode ("utf8" )
1050+ TestPDB .flush (child )
1051+
10281052
10291053def test_trace_after_runpytest (testdir ):
10301054 """Test that debugging's pytest_configure is re-entrant."""
You can’t perform that action at this time.
0 commit comments