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

Method test_exec_counts

Lib/test/test_trace.py:245–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

243 @unittest.skipIf(os.environ.get('PYTHON_UOPS_OPTIMIZE') == '0',
244 "Line counts differ when JIT optimizer is disabled")
245 def test_exec_counts(self):
246 self.tracer = Trace(count=1, trace=0, countfuncs=0, countcallers=0)
247 code = r'''traced_func_loop(2, 5)'''
248 code = compile(code, __file__, 'exec')
249 self.tracer.runctx(code, globals(), vars())
250
251 firstlineno = get_firstlineno(traced_func_loop)
252 expected = {
253 (self.my_py_filename, firstlineno + 1): 1,
254 (self.my_py_filename, firstlineno + 2): 6,
255 (self.my_py_filename, firstlineno + 3): 5,
256 (self.my_py_filename, firstlineno + 4): 1,
257 }
258
259 # When used through 'run', some other spurious counts are produced, like
260 # the settrace of threading, which we ignore, just making sure that the
261 # counts fo traced_func_loop were right.
262 #
263 for k in expected.keys():
264 self.assertEqual(self.tracer.results().counts[k], expected[k])
265
266
267class TestFuncs(unittest.TestCase):

Callers

nothing calls this directly

Calls 7

TraceClass · 0.90
get_firstlinenoFunction · 0.85
resultsMethod · 0.80
compileFunction · 0.50
runctxMethod · 0.45
keysMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected