Commits

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
  • Tags RELEASE_1_2

Comments (0)

Files changed (3)

File pytest_cov.py

 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',
                     dest='cov_source',
-                    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'],
                     dest='cov_report',
     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')
 import setuptools
 
 setuptools.setup(name='pytest-cov',
-                 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',
                  long_description=open('README.txt').read().strip(),
                  author='Meme Dough',
                  author_email='memedough@gmail.com',
                  py_modules=['pytest_cov'],
                  install_requires=['py>=1.3.3',
                                    'pytest-xdist>=1.4',
-                                   'cov-core>=1.0'],
+                                   'cov-core>=1.1'],
                  entry_points={'pytest11': ['pytest_cov = pytest_cov']},
                  license='MIT License',
                  zip_safe=False,

File test_pytest_cov.py

     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'):