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

Method test_self_trace

Lib/test/test_external_inspection.py:1376–1394  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1374 "Test only runs on Linux with process_vm_readv support",
1375 )
1376 def test_self_trace(self):
1377 stack_trace = get_stack_trace(os.getpid())
1378
1379 this_thread_stack = None
1380 for interpreter_info in stack_trace:
1381 for thread_info in interpreter_info.threads:
1382 if thread_info.thread_id == threading.get_native_id():
1383 this_thread_stack = thread_info.frame_info
1384 break
1385 if this_thread_stack:
1386 break
1387
1388 self.assertIsNotNone(this_thread_stack)
1389 # Check the top two frames
1390 self.assertGreaterEqual(len(this_thread_stack), 2)
1391 self.assertEqual(this_thread_stack[0].funcname, "get_stack_trace")
1392 self.assertTrue(this_thread_stack[0].filename.endswith("test_external_inspection.py"))
1393 self.assertEqual(this_thread_stack[1].funcname, "TestGetStackTrace.test_self_trace")
1394 self.assertTrue(this_thread_stack[1].filename.endswith("test_external_inspection.py"))
1395
1396 @skip_if_not_supported
1397 @unittest.skipIf(

Callers

nothing calls this directly

Calls 6

get_stack_traceFunction · 0.85
assertIsNotNoneMethod · 0.80
assertGreaterEqualMethod · 0.80
assertTrueMethod · 0.80
assertEqualMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected