]> granicus.if.org Git - python/commitdiff
bpo-34171: Fix test_trace. (GH-8940)
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 27 Aug 2018 10:10:36 +0000 (13:10 +0300)
committerGitHub <noreply@github.com>
Mon, 27 Aug 2018 10:10:36 +0000 (13:10 +0300)
Remove "trace.cover" left from previous test runs before testing
that it is no longer created.

Lib/test/test_trace.py

index 3b335ca42f90eebaaa1f035c708c8edc4dac99a2..63f474179d68c21a31e852e659f9b26f37c284da 100644 (file)
@@ -385,13 +385,16 @@ class TestCoverageCommandLineOutput(unittest.TestCase):
         unlink(self.coverfile)
 
     def test_cover_files_written_no_highlight(self):
+        # Test also that the cover file for the trace module is not created
+        # (issue #34171).
+        tracedir = os.path.dirname(os.path.abspath(trace.__file__))
+        tracecoverpath = os.path.join(tracedir, 'trace.cover')
+        unlink(tracecoverpath)
+
         argv = '-m trace --count'.split() + [self.codefile]
         status, stdout, stderr = assert_python_ok(*argv)
         self.assertEqual(stderr, b'')
-        tracedir = os.path.dirname(os.path.abspath(trace.__file__))
-        tracecoverpath = os.path.join(tracedir, "trace.cover")
         self.assertFalse(os.path.exists(tracecoverpath))
-
         self.assertTrue(os.path.exists(self.coverfile))
         with open(self.coverfile) as f:
             self.assertEqual(f.read(),