MCPcopy Index your code
hub / github.com/python/cpython / test_cantrace

Function test_cantrace

Lib/test/audit-tests.py:269–299  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

267
268
269def test_cantrace():
270 traced = []
271
272 def trace(frame, event, *args):
273 if frame.f_code == TestHook.__call__.__code__:
274 traced.append(event)
275
276 old = sys.settrace(trace)
277 try:
278 with TestHook() as hook:
279 # No traced call
280 eval("1")
281
282 # No traced call
283 hook.__cantrace__ = False
284 eval("2")
285
286 # One traced call
287 hook.__cantrace__ = True
288 eval("3")
289
290 # Two traced calls (writing to private member, eval)
291 hook.__cantrace__ = 1
292 eval("4")
293
294 # One traced call (writing to private member)
295 hook.__cantrace__ = 0
296 finally:
297 sys.settrace(old)
298
299 assertSequenceEqual(["call"] * 4, traced)
300
301
302def test_mmap():

Callers

nothing calls this directly

Calls 2

assertSequenceEqualFunction · 0.85
TestHookClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…