MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_pdb_wrapper_class_is_reused

Function test_pdb_wrapper_class_is_reused

testing/test_debugging.py:1300–1327  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

1298
1299
1300def test_pdb_wrapper_class_is_reused(pytester: Pytester) -> None:
1301 p1 = pytester.makepyfile(
1302 """
1303 def test():
1304 __import__("pdb").set_trace()
1305 __import__("pdb").set_trace()
1306
1307 import mypdb
1308 instances = mypdb.instances
1309 assert len(instances) == 2
1310 assert instances[0].__class__ is instances[1].__class__
1311 """,
1312 mypdb="""
1313 instances = []
1314
1315 class MyPdb:
1316 def __init__(self, *args, **kwargs):
1317 instances.append(self)
1318
1319 def set_trace(self, *args):
1320 print("set_trace_called", args)
1321 """,
1322 )
1323 result = pytester.runpytest(str(p1), "--pdbcls=mypdb:MyPdb", syspathinsert=True)
1324 assert result.ret == 0
1325 result.stdout.fnmatch_lines(
1326 ["*set_trace_called*", "*set_trace_called*", "* 1 passed in *"]
1327 )

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected