summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_trace.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-09-24 18:08:24 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-09-24 18:08:24 (GMT)
commit402392bd5afffedf38b0270a3122e4687bdd13a2 (patch)
tree7fbd9df30200dfeaa7f6343e970c6ded0dd534fb /Lib/test/test_trace.py
parenta4c8ecd32efe42895a21a1b0836c35559f8a6b23 (diff)
downloadcpython-402392bd5afffedf38b0270a3122e4687bdd13a2.zip
cpython-402392bd5afffedf38b0270a3122e4687bdd13a2.tar.gz
cpython-402392bd5afffedf38b0270a3122e4687bdd13a2.tar.bz2
Merged revisions 84994 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84994 | alexander.belopolsky | 2010-09-24 14:03:12 -0400 (Fri, 24 Sep 2010) | 1 line Issue #9936: Fixed executable lines' search in the trace module. ........
Diffstat (limited to 'Lib/test/test_trace.py')
-rw-r--r--Lib/test/test_trace.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 2bb1f33..20d0360 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -166,7 +166,6 @@ class TestLineCounts(unittest.TestCase):
}
self.assertEqual(tracer.results().counts, expected)
-
class TestRunExecCounts(unittest.TestCase):
"""A simple sanity test of line-counting, via runctx (exec)"""
def setUp(self):
@@ -263,8 +262,9 @@ class TestCoverage(unittest.TestCase):
rmtree(TESTFN)
unlink(TESTFN)
- def _coverage(self, tracer):
- tracer.run('from test import test_pprint; test_pprint.test_main()')
+ def _coverage(self, tracer,
+ cmd='from test import test_pprint; test_pprint.test_main()'):
+ tracer.run(cmd)
r = tracer.results()
r.write_results(show_missing=True, summary=True, coverdir=TESTFN)
@@ -291,6 +291,25 @@ class TestCoverage(unittest.TestCase):
files = os.listdir(TESTFN)
self.assertEquals(files, [])
+ 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]))
+ self.assertIn(modname, coverage)
+ self.assertEqual(coverage[modname], (5, 100))
+
def test_main():
run_unittest(__name__)