aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_trace.py
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2018-08-11 09:15:43 +0300
committerGitHub <noreply@github.com>2018-08-11 09:15:43 +0300
commitc8b0dbc4928a1fe4bd5abebd810b6849374c7af3 (patch)
tree9478150d4fa5d3feb8ddbbfc88a6f38b806e004b /Lib/test/test_trace.py
parent84a13fbda0d79789e3c9efcc9f64752261ce1e8d (diff)
downloadcpython-c8b0dbc4928a1fe4bd5abebd810b6849374c7af3.tar.gz
cpython-c8b0dbc4928a1fe4bd5abebd810b6849374c7af3.zip
bpo-26818: Add a test to make sure the bug is fixed (GH-8664)
The main cause of this bug was fixed as part of bpo-31908.
Diffstat (limited to 'Lib/test/test_trace.py')
-rw-r--r--Lib/test/test_trace.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 55a8bcea3e5..dc9b3fa7b6a 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -438,5 +438,27 @@ class TestCommandLine(unittest.TestCase):
status, trace_stdout, stderr = assert_python_ok('-m', 'trace', '-l', TESTFN)
self.assertIn(direct_stdout.strip(), trace_stdout)
+ def test_count_and_summary(self):
+ filename = f'{TESTFN}.py'
+ coverfilename = f'{TESTFN}.cover'
+ with open(filename, 'w') as fd:
+ self.addCleanup(unlink, filename)
+ self.addCleanup(unlink, coverfilename)
+ fd.write(textwrap.dedent("""\
+ x = 1
+ y = 2
+
+ def f():
+ return x + y
+
+ for i in range(10):
+ f()
+ """))
+ status, stdout, _ = assert_python_ok('-m', 'trace', '-cs', filename)
+ stdout = stdout.decode()
+ self.assertEqual(status, 0)
+ self.assertIn('lines cov% module (path)', stdout)
+ self.assertIn(f'6 100% {TESTFN} ({filename})', stdout)
+
if __name__ == '__main__':
unittest.main()