Anonymous avatar Anonymous committed b696fbf

Limit coverage to python files.

Comments (0)

Files changed (3)

         morfs = list(set(module.__file__
                          for name, module in sys.modules.items()
                          for package in cov_packages
-                         if hasattr(module, '__file__') and name.startswith(package)))
+                         if hasattr(module, '__file__') and
+                         os.path.splitext(module.__file__)[1] in ('.py', '.pyc', '.pyo') and
+                         name.startswith(package)))
 
         for cov, node_descs in self.covs:
 
 import setuptools
 
 setuptools.setup(name='pytest-cov',
-                 version='0.9',
+                 version='0.10',
                  description='py.test plugin for coverage reporting with support for both centralised and distributed testing',
                  long_description=open('README.txt').read().strip(),
                  author='Meme Dough',

test_pytest_cov.py

         pass
 '''
 
+SCRIPT_CMATH = '''
+import cmath
+
+def test_foo():
+    pass
+'''
+
 @py.test.mark.xfail('sys.version_info[:2] == (3, 0)')
 def test_central(testdir):
     script = testdir.makepyfile(SCRIPT)
             ])
     assert result.ret == 0
 
+def test_module_selection(testdir):
+    script = testdir.makepyfile(SCRIPT_CMATH)
+    result = testdir.runpytest(script,
+                               '--cov=cmath',
+                               '--cov=%s' % script.purebasename)
+    result.stdout.fnmatch_lines([
+            '*- coverage: platform *, python * -*',
+            'test_module_selection * 3 * 0 * 100% *',
+            '*1 passed*'
+            ])
+    assert result.ret == 0
+    matching_lines = [line for line in result.outlines if 'TokenError' in line]
+    assert not matching_lines
+
 @py.test.mark.xfail('sys.version_info[:2] == (3, 0)')
 def test_dist_load_collocated(testdir):
     script = testdir.makepyfile(SCRIPT)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.