Commits

Ned Batchelder  committed cbb7946

Don't let parallel=True prevent reporting. Fixes #49.

  • Participants
  • Parent commits 7d95ed6

Comments (0)

Files changed (3)

 Version 3.3.1
 -------------
 
+- Using `parallel=True` in .coveragerc file prevented reporting, but now does
+  not, fixing `issue 49`.
+
 - When running your code with "coverage run", if you call `sys.exit()`,
   coverage.py will exit with that status code, fixing `issue 50`.
-  
+
+.. _issue 49: http://bitbucket.org/ned/coveragepy/issue/49
 .. _issue 50: http://bitbucket.org/ned/coveragepy/issue/50
 
 

File coverage/control.py

                     )
         else:
             data_suffix = None
+        self.run_suffix = data_suffix
 
         self.data = CoverageData(
-            basename=self.config.data_file, suffix=data_suffix,
+            basename=self.config.data_file,
             collector="coverage v%s" % __version__
             )
 
 
     def start(self):
         """Start measuring code coverage."""
+        if self.run_suffix:
+            # If the .coveragerc file specifies parallel=True, then we need to
+            # remake the data file for collection, with a suffix.
+            from coverage import __version__
+            self.data = CoverageData(
+                basename=self.config.data_file, suffix=self.run_suffix,
+                collector="coverage v%s" % __version__
+                )
         if self.auto_data:
             self.load()
             # Save coverage data when Python exits.
         current measurements.
 
         """
-        # If the .coveragerc file specifies parallel=True, then self.data
-        # already points to a suffixed data file.  This won't be right for
-        # combining, so make a new self.data with no suffix.
-        from coverage import __version__
-        self.data = CoverageData(
-            basename=self.config.data_file,
-            collector="coverage v%s" % __version__
-            )
         self.data.combine_parallel_data()
 
     def _harvest_data(self):

File test/test_process.py

 """Tests for process behavior of coverage.py."""
 
-import os, sys
+import os, sys, textwrap
 import coverage
 
 sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
         data.read_file(".coverage")
         self.assertEqual(data.summary()['b_or_c.py'], 7)
 
-        # TODO
-        ## Reporting should still work even with the .rc file
-        #out = self.run_command("coverage report")
-        #self.assertMultiLineEqual(out, """\
-        #    hello
-        #    """)
+        # Reporting should still work even with the .rc file
+        out = self.run_command("coverage report")
+        self.assertMultiLineEqual(out, textwrap.dedent("""\
+            Name     Stmts   Exec  Cover
+            ----------------------------
+            b_or_c       7      7   100%
+            """))
 
     def test_missing_source_file(self):
         # Check what happens if the source is missing when reporting happens.