[checker] allow to exclude files from pycoverage analysis
authorDavid Douard <david.douard@logilab.fr>
Tue, 22 Dec 2015 11:05:27 +0100
changeset 1853 746d21ef4c02
parent 1847 18c144a672f8
child 1854 f1cb7556f384
[checker] allow to exclude files from pycoverage analysis Closes #9764957
_narval/checkers/apycot/python.py
--- a/_narval/checkers/apycot/python.py	Tue Dec 22 10:25:34 2015 +0100
+++ b/_narval/checkers/apycot/python.py	Tue Dec 22 11:05:27 2015 +0100
@@ -192,6 +192,11 @@
         'help': ('Tell if test should be run with pycoverage to gather '
                  'coverage data.'),
         },
+    'pycoverage_excludes': {
+        'type': 'csv',
+        'help': ('comma separated list of python files to exclude from '
+                 'coverage analysis'),
+        },
     }
 
 class PyTestChecker(BaseChecker):
@@ -393,8 +398,13 @@
     def get_command(self, command, python):
         python = [python, '-W', 'ignore']
         if self.enable_coverage():
+            excludes = self.options.get("pycoverage_excludes", [])
+            if not isinstance(excludes, list):
+                excludes = [excludes]
             python += ['-m', 'coverage', 'run', '-a', '--branch',
                        '--source=%s' % pyinstall_path(self.test)]
+            if excludes:
+                python += ['--omit', ','.join(excludes)]
         return python + command
 
 register('checker', PyUnitTestChecker)