Commits

Anonymous committed 12a89d7

Changed to work with current released coverage.

Comments (0)

Files changed (3)

 cov-core
 ========
 
-This is a lib package for use by pytest-cov and nose-cov.  Unless your
-developing a coverage plugin for a test framework then you probably
-want one of those.
+This is a lib package for use by pytest-cov, nose-cov and unittest2-cov.  Unless your developing a
+coverage plugin for a test framework then you probably want one of those.
     def summary(self, stream):
         """Produce coverage reports."""
 
+        # Determine the modules or files to limit reports on.
+        morfs = list(set(module.__file__
+                         for name, module in sys.modules.items()
+                         for package in self.cov_source
+                         if hasattr(module, '__file__') and
+                         os.path.splitext(module.__file__)[1] in ('.py', '.pyc', '.pyo') and
+                         name.startswith(package)))
+
         # Produce terminal report if wanted.
         if 'term' in self.cov_report or 'term-missing' in self.cov_report:
             if len(self.node_descs) == 1:
                 for node_desc in sorted(self.node_descs):
                     self.sep(stream, ' ', '%s' % node_desc)
             show_missing = 'term-missing' in self.cov_report
-            self.cov.report(show_missing=show_missing, ignore_errors=True, file=stream)
+            #self.cov.report(show_missing=show_missing, ignore_errors=True, file=stream)
+            self.cov.report(morfs, show_missing=show_missing, ignore_errors=True, file=stream)
 
         # Produce annotated source code report if wanted.
         if 'annotate' in self.cov_report:
-            self.cov.annotate(ignore_errors=True)
+            #self.cov.annotate(ignore_errors=True)
+            self.cov.annotate(morfs, ignore_errors=True)
 
         # Produce html report if wanted.
         if 'html' in self.cov_report:
-            self.cov.html_report(ignore_errors=True)
+            #self.cov.html_report(ignore_errors=True)
+            self.cov.html_report(morfs, ignore_errors=True)
 
         # Produce xml report if wanted.
         if 'xml' in self.cov_report:
-            self.cov.xml_report(ignore_errors=True)
+            #self.cov.xml_report(ignore_errors=True)
+            self.cov.xml_report(morfs, ignore_errors=True)
 
         # Report on any failed slaves.
         if self.failed_slaves:
     def start(self):
         """Erase any previous coverage data and start coverage."""
 
-        self.cov = coverage.coverage(source=self.cov_source,
+        self.cov = coverage.coverage(#source=self.cov_source,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
         # If slave is not collocated then we must save the data file
         # that it returns to us.
         if 'cov_slave_lines' in node.slaveoutput:
-            cov = coverage.coverage(source=self.cov_source,
+            cov = coverage.coverage(#source=self.cov_source,
                                     data_file=self.cov_data_file,
                                     data_suffix=node.slaveoutput['cov_slave_node_id'],
                                     config_file=self.cov_config)
         """Combines coverage data and sets the list of coverage objects to report on."""
 
         # Combine all the suffix files into the data file.
-        self.cov = coverage.coverage(source=self.cov_source,
+        self.cov = coverage.coverage(#source=self.cov_source,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
         self.cov_data_file += '.%s' % self.nodeid
 
         # Erase any previous data and start coverage.
-        self.cov = coverage.coverage(source=self.cov_source,
+        self.cov = coverage.coverage(#source=self.cov_source,
                                      data_file=self.cov_data_file,
                                      config_file=self.cov_config)
         self.cov.erase()
 import cov_core_init; cov_core_init.init()
 '''
 
-UNKNOWN_SITE_PACKAGES_DIR ='''\
+UNKNOWN_SITE_PACKAGES_DIR ='''
 Failed to find site-packages or dist-packages dir to put pth file in.
 Sub processes will not have coverage collected.
 
 ''' % (PTH_FILE_NAME, PTH_FILE)
 
 setuptools.setup(name='cov-core',
-                 version='1.0a2',
-                 description='plugin core for use by pytest-cov and nose-cov',
+                 version='1.0',
+                 description='plugin core for use by pytest-cov, nose-cov and unittest2-cov',
                  long_description=open('README.txt').read().strip(),
                  author='Meme Dough',
                  author_email='memedough@gmail.com',
                  url='http://bitbucket.org/memedough/cov-core/overview',
                  py_modules=['cov_core',
                              'cov_core_init'],
-                 install_requires=['coverage>=3.4a1'],
+                 install_requires=['coverage>=3.3.1'],
                  license='MIT License',
                  zip_safe=False,
                  keywords='cover coverage',
 
 if sys.argv[1] in ('install', 'develop'):
     for path in sys.path:
-        if 'site-packages' in path or 'dist-packages' in path:
-            path = os.path.dirname(path)
-            pth_file = open(os.path.join(path, PTH_FILE_NAME), 'w')
+        if ('site-packages' in path) or ('dist-packages' in path and 'local' in path):
+            path = os.path.join(path, PTH_FILE_NAME)
+            pth_file = open(path, 'w')
             pth_file.write(PTH_FILE)
             pth_file.close()
+            sys.stdout.write('\nWrote pth file for subprocess measurement to %s\n' % path)
             break
     else:
         sys.stdout.write(UNKNOWN_SITE_PACKAGES_DIR)
-        sys.stdout.write(PTH_FILE)