Commits

David Stanek  committed 0302121

refactored the plugin's finish method to better enable filtering modules from a report

  • Participants
  • Parent commits 0de4cb4

Comments (0)

Files changed (1)

File coverage/testplugin.py

         self.coverage.stop()
         self.coverage.save()
 
-        modules = []
-        if self.coverPackages:
-            for name, module in sys.modules.items():
-                for package in self.coverPackages:
-                    if module is not None and name.startswith(package):
-                        modules.append(module)
+        modules = [module for name, module in sys.modules.items()
+                   if self._want_module(name, module)]
 
         # Remaining actions are reporting, with some common self.options.
         report_args = {
         
         return
 
+    def _want_module(self, name, module):
+        for package in self.coverPackages:
+            if module is not None and name.startswith(package):
+                return True
+
+        return False
+
+
 options = [
     optparse.Option('',
                 '--cover-action', action='append', default=['report'],