def test_issue9936(self):
tracer = trace.Trace(trace=0, count=1)
modname = 'test.tracedmodules.testmod'
# Ensure that the module is executed in import
if modname in sys.modules:
del sys.modules[modname]
cmd = ("import test.tracedmodules.testmod as t;"
"t.func(0); t.func2();")
with captured_stdout() as stdout:
self._coverage(tracer, cmd)
stdout.seek(0)
stdout.readline()
coverage = {}
for line in stdout:
lines, cov, module = line.split()[:3]
coverage[module] = (int(lines), int(cov[:-1]))
# XXX This is needed to run regrtest.py as a script
modname = trace._fullmodname(sys.modules[modname].__file__)
self.assertIn(modname, coverage)
self.assertEqual(coverage[modname], (5, 100))
### Tests that don't mess with sys.settrace and can be traced
### themselves TODO: Skip tests that do mess with sys.settrace when
### regrtest is invoked with -T option.
评论列表
文章目录