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

Method test_create_snapshot

Lib/test/test_tracemalloc.py:390–409  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

388 maxDiff = 4000
389
390 def test_create_snapshot(self):
391 raw_traces = [(0, 5, (('a.py', 2),), 10)]
392
393 with contextlib.ExitStack() as stack:
394 stack.enter_context(patch.object(tracemalloc, 'is_tracing',
395 return_value=True))
396 stack.enter_context(patch.object(tracemalloc, 'get_traceback_limit',
397 return_value=5))
398 stack.enter_context(patch.object(tracemalloc, '_get_traces',
399 return_value=raw_traces))
400
401 snapshot = tracemalloc.take_snapshot()
402 self.assertEqual(snapshot.traceback_limit, 5)
403 self.assertEqual(len(snapshot.traces), 1)
404 trace = snapshot.traces[0]
405 self.assertEqual(trace.size, 5)
406 self.assertEqual(trace.traceback.total_nframe, 10)
407 self.assertEqual(len(trace.traceback), 1)
408 self.assertEqual(trace.traceback[0].filename, 'a.py')
409 self.assertEqual(trace.traceback[0].lineno, 2)
410
411 def test_filter_traces(self):
412 snapshot, snapshot2 = create_snapshots()

Callers

nothing calls this directly

Calls 2

enter_contextMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected