1. memedough
  2. pytest-cov


Meme Dough  committed 4ad3116

Changes to cov option, reporting and imports.

Change cov option to work on filesystem paths and make the help
text more clear.

Change reporting to indicating files and dirs written to. Also
output warning if nothing to report on.

Minimise imports by only importing if actually needed.

  • Participants
  • Parent commits 9529e36
  • Branches default
  • Tags RELEASE_1_2

Comments (0)

Files changed (3)

File pytest_cov.py

View file
 No doubt others have contributed to these tools as well.
-import cov_core
 def pytest_addoption(parser):
     """Add options to control coverage."""
     group = parser.getgroup('coverage reporting with distributed testing support')
     group.addoption('--cov', action='append', default=[], metavar='path',
-                    help='measure coverage for path (multi-allowed)')
+                    help='measure coverage for filesystem path (multi-allowed)')
     group.addoption('--cov-report', action='append', default=[], metavar='type',
                     choices=['term', 'term-missing', 'annotate', 'html', 'xml'],
     def pytest_sessionstart(self, session):
         """At session start determine our implementation and delegate to it."""
+        import cov_core
         cov_source = session.config.getvalue('cov_source')
         cov_report = session.config.getvalue('cov_report') or ['term']
         cov_config = session.config.getvalue('cov_config')

File setup.py

View file
 import setuptools
-                 version='1.1',
-                 description='py.test plugin for coverage reporting with support for both centralised and distributed testing',
+                 version='1.2',
+                 description='py.test plugin for coverage reporting with support for both centralised and distributed testing, including subprocesses',
                  author='Meme Dough',
-                                   'cov-core>=1.0'],
+                                   'cov-core>=1.1'],
                  entry_points={'pytest11': ['pytest_cov = pytest_cov']},
                  license='MIT License',

File test_pytest_cov.py

View file
     assert result.ret == 0
+def test_empty_report(testdir):
+    script = testdir.makepyfile(SCRIPT)
+    result = testdir.runpytest(script,
+                               '--cov=non_existent_module',
+                               '--cov-report=term-missing')
+    result.stdout.fnmatch_lines([
+            '*- coverage: platform *, python * -*',
+            '*10 passed*'
+            ])
+    assert result.ret == 0
+    matching_lines = [line for line in result.outlines if '%' in line]
+    assert not matching_lines
 @py.test.mark.skipif('sys.version_info[:2] >= (3, 0)')
 def test_dist_missing_data(testdir):
     if not os.path.exists('/usr/local/python255-empty/bin/python'):