]> granicus.if.org Git - python/commitdiff
bpo-26818: Add a test to make sure the bug is fixed (GH-8664)
authorBerker Peksag <berker.peksag@gmail.com>
Sat, 11 Aug 2018 06:15:43 +0000 (09:15 +0300)
committerGitHub <noreply@github.com>
Sat, 11 Aug 2018 06:15:43 +0000 (09:15 +0300)
The main cause of this bug was fixed as part of bpo-31908.

Lib/test/test_trace.py

index 55a8bcea3e546ad9657155816b3b59ebc0330363..dc9b3fa7b6af8c33fd0698192ab457144f8e638e 100644 (file)
@@ -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()