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

Method test_lltrace_different_module

Lib/test/test_lltrace.py:66–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

64 self.assertNotIn("'dont_trace_2' in module", stdout)
65
66 def test_lltrace_different_module(self):
67 stdout = self.run_code("""
68 from test import test_lltrace
69 test_lltrace.__lltrace__ = 1
70 test_lltrace.example()
71 """)
72 self.assertIn("'example' in module 'test.test_lltrace'", stdout)
73 self.assertIn('LOAD_CONST', stdout)
74 self.assertIn('FOR_ITER', stdout)
75 self.assertIn('this is an example', stdout)
76
77 # check that offsets match the output of dis.dis()
78 instr_map = {i.offset: i for i in dis.get_instructions(example, adaptive=True)}
79 for line in stdout.splitlines():
80 offset, colon, opname_oparg = line.partition(":")
81 if not colon:
82 continue
83 offset = int(offset)
84 opname_oparg = opname_oparg.split()
85 if len(opname_oparg) == 2:
86 opname, oparg = opname_oparg
87 oparg = int(oparg)
88 else:
89 (opname,) = opname_oparg
90 oparg = None
91 self.assertEqual(instr_map[offset].opname, opname)
92 self.assertEqual(instr_map[offset].arg, oparg)
93
94 def test_lltrace_does_not_crash_on_subscript_operator(self):
95 # If this test fails, it will reproduce a crash reported as

Callers

nothing calls this directly

Calls 7

run_codeMethod · 0.95
assertInMethod · 0.80
get_instructionsMethod · 0.80
splitlinesMethod · 0.45
partitionMethod · 0.45
splitMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected