Skip to content

Instantly share code, notes, and snippets.

  • Save mccutchen/1038337 to your computer and use it in GitHub Desktop.
Save mccutchen/1038337 to your computer and use it in GitHub Desktop.
From 5761a54ec9553c704c0782d5c581c2178f8e32b1 Mon Sep 17 00:00:00 2001
From: Will McCutchen <[email protected]>
Date: Mon, 4 Apr 2011 15:13:09 -0500
Subject: [PATCH] Stop caring about coverage omissions when running tests with code coverage. Let anyone creating coverage reports worry about them.
---
shared/fabric/utils.py | 30 +++---------------------------
1 files changed, 3 insertions(+), 27 deletions(-)
diff --git a/shared/fabric/utils.py b/shared/fabric/utils.py
index 1ec5323..c8f2eee 100644
--- a/shared/fabric/utils.py
+++ b/shared/fabric/utils.py
@@ -92,37 +92,14 @@ def make_test_command(*modules, **kwargs):
"""Creates a fabric command, test, to run the tests for the given
modules.
- Two keyword args are supported, omit and omit_ki. If omit is given, it is
- a list of patterns to omit from test coverage. If omit_ki is given, it is
- a bool that determines whether the entire ki submodule is excluded from
- test coverage.
-
Example usage, in a fabfile.py:
test = utils.make_test_command('api', 'store')
Now, running `fab test` will execute the unit tests in the api.tests and
- store.tests modules. Or, to use the omit keyword argument:
-
- test = utiles.make_test_command('api', omit=['ki/ext/*])
-
- Now, running `fab test` will exececute the unit tests in the api.tests
- module but exclude anything in `ki/ext` from test coverage.
+ store.tests modules.
"""
- # Figure out what, if anything, we will omit from test coverage
- default_omit = [
- '/*google*', '/*django*', '/*WebTest*', '/*test*', '*.txt', '*.json',
- '*.html']
- omit_ki = kwargs.pop('omit_ki', False)
- if omit_ki:
- default_omit += ['ki/*']
- else:
- default_omit += ['ki/ext/*', 'ki/webapp/*']
-
- project_omit = kwargs.pop('omit', [])
- omit = default_omit + project_omit
-
def test(coverage=None, verbose=None, loglevel='WARN'):
# The docstring will be added after this function is defined, so it
# can be dynamically updated to include the modules that will be
@@ -154,7 +131,7 @@ def make_test_command(*modules, **kwargs):
'info will be generated.')
cov = None
else:
- cov = coverage.coverage(omit=omit)
+ cov = coverage.coverage()
else:
cov = None
@@ -173,9 +150,8 @@ def make_test_command(*modules, **kwargs):
# If we have a coverage object, turn off coverage and save the results
if cov is not None:
cov.stop()
+ logging.info('Saving coverage info...')
cov.save()
- print header('Coverage report')
- cov.report()
# Add the docstring to the test command we just created, so that fab can
# show appropriate help.
--
1.7.3.4+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment