@@ -1025,6 +1025,51 @@ def test_3():
1025
1025
assert "Exit: Quitting debugger" not in child .before .decode ("utf8" )
1026
1026
TestPDB .flush (child )
1027
1027
1028
+ def test_trace_with_parametrize_handles_shared_fixtureinfo (self , testdir ):
1029
+ p1 = testdir .makepyfile (
1030
+ """
1031
+ import pytest
1032
+ @pytest.mark.parametrize('myparam', [1,2])
1033
+ def test_1(myparam, request):
1034
+ assert myparam in (1, 2)
1035
+ assert request.function.__name__ == "test_1"
1036
+ @pytest.mark.parametrize('func', [1,2])
1037
+ def test_func(func, request):
1038
+ assert func in (1, 2)
1039
+ assert request.function.__name__ == "test_func"
1040
+ @pytest.mark.parametrize('myparam', [1,2])
1041
+ def test_func_kw(myparam, request, func="func_kw"):
1042
+ assert myparam in (1, 2)
1043
+ assert func == "func_kw"
1044
+ assert request.function.__name__ == "test_func_kw"
1045
+ """
1046
+ )
1047
+ child = testdir .spawn_pytest ("--trace " + str (p1 ))
1048
+ for func , argname in [
1049
+ ("test_1" , "myparam" ),
1050
+ ("test_func" , "func" ),
1051
+ ("test_func_kw" , "myparam" ),
1052
+ ]:
1053
+ child .expect_exact ("> PDB runcall (IO-capturing turned off) >" )
1054
+ child .expect_exact (func )
1055
+ child .expect_exact ("Pdb" )
1056
+ child .sendline ("args" )
1057
+ child .expect_exact ("{} = 1\r \n " .format (argname ))
1058
+ child .expect_exact ("Pdb" )
1059
+ child .sendline ("c" )
1060
+ child .expect_exact ("Pdb" )
1061
+ child .sendline ("args" )
1062
+ child .expect_exact ("{} = 2\r \n " .format (argname ))
1063
+ child .expect_exact ("Pdb" )
1064
+ child .sendline ("c" )
1065
+ child .expect_exact ("> PDB continue (IO-capturing resumed) >" )
1066
+ rest = child .read ().decode ("utf8" )
1067
+ assert "6 passed in" in rest
1068
+ assert "reading from stdin while output" not in rest
1069
+ # Only printed once - not on stderr.
1070
+ assert "Exit: Quitting debugger" not in child .before .decode ("utf8" )
1071
+ TestPDB .flush (child )
1072
+
1028
1073
1029
1074
def test_trace_after_runpytest (testdir ):
1030
1075
"""Test that debugging's pytest_configure is re-entrant."""
@@ -1143,14 +1188,14 @@ def test():
1143
1188
__import__("pdb").set_trace()
1144
1189
""" ,
1145
1190
mypdb = """
1191
+ import pdb
1146
1192
class Wrapped:
1147
- class MyPdb:
1193
+ class MyPdb(pdb.Pdb) :
1148
1194
def set_trace(self, *args):
1149
1195
print("set_trace_called", args)
1150
1196
1151
- def runcall(self, *args, **kwds):
1152
- print("runcall_called", args, kwds)
1153
- assert "func" in kwds
1197
+ def trace_dispatch(self, frame, event, arg):
1198
+ print("trace_dispatch called", frame, event, arg)
1154
1199
""" ,
1155
1200
)
1156
1201
result = testdir .runpytest (
@@ -1175,7 +1220,7 @@ def runcall(self, *args, **kwds):
1175
1220
str (p1 ), "--pdbcls=mypdb:Wrapped.MyPdb" , "--trace" , syspathinsert = True
1176
1221
)
1177
1222
assert result .ret == 0
1178
- result .stdout .fnmatch_lines (["*runcall_called *" , "* 1 passed in *" ])
1223
+ result .stdout .fnmatch_lines (["*trace_dispatch called *" , "* 1 passed in *" ])
1179
1224
1180
1225
1181
1226
def test_raises_bdbquit_with_eoferror (testdir ):
0 commit comments