From bdf8683c17aa8e1cb35b3dc844cf1ab1b723ea22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:24:10 +0200 Subject: [PATCH 1/6] Add egg-info in ignore list --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0d20b64..7fdea58 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +*.egg-info From 81d4443b9ba3f3fce3028521da5667df0d66df8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:24:53 +0200 Subject: [PATCH 2/6] Update TestRunner to use module path given to test command --- django_coverage/coverage_runner.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/django_coverage/coverage_runner.py b/django_coverage/coverage_runner.py index 8fc95b4..d87d123 100644 --- a/django_coverage/coverage_runner.py +++ b/django_coverage/coverage_runner.py @@ -15,7 +15,6 @@ """ import os -import sys import django @@ -77,9 +76,11 @@ def run_tests(self, test_labels, extra_tests=None, **kwargs): coverage.stop() coverage_modules = [] - if test_labels: + + if test_labels and all( + [len(label.split('.')) >= 2 for label in test_labels]): for label in test_labels: - label = label.split('.')[0] + label = label.split('.')[1] app = get_app(label) coverage_modules.append(self._get_app_package(app)) else: @@ -118,6 +119,6 @@ def run_tests(self, test_labels, extra_tests=None, **kwargs): else: coverage._the_coverage.html_report(list(modules.values()), outdir) print("") - print("HTML reports were output to '%s'" %outdir) + print("HTML reports were output to '%s'" % outdir) return results From d4679223cc215eed12e978f63f31b17f4eb5178b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:25:22 +0200 Subject: [PATCH 3/6] Use test command instead of test_coverage --- .../commands/{test_coverage.py => test.py} | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) rename django_coverage/management/commands/{test_coverage.py => test.py} (63%) diff --git a/django_coverage/management/commands/test_coverage.py b/django_coverage/management/commands/test.py similarity index 63% rename from django_coverage/management/commands/test_coverage.py rename to django_coverage/management/commands/test.py index 90dfb83..5404ba9 100755 --- a/django_coverage/management/commands/test_coverage.py +++ b/django_coverage/management/commands/test.py @@ -13,26 +13,31 @@ See the License for the specific language governing permissions and limitations under the License. """ +from optparse import make_option from django.conf import settings -from django.core.management import call_command from django.core.management.commands import test from django_coverage import settings as coverage_settings -class Command(test.Command): - help = ("Runs the test suite for the specified applications, or the " - "entire site if no apps are specified. Then generates coverage " - "report both onscreen and as HTML.") - def handle(self, *test_labels, **options): +class Command(test.Command): + def __init__(self, *args, **kwargs): + super(Command, self).__init__(*args, **kwargs) + self.option_list += ( + make_option( + '--with-coverage', + action="store_true", dest="with_coverage", default=False, + help="Use Coverage TestRunner to generate coverage."), ) + + def handle(self, *args, **kwargs): """ Replaces the original test runner with the coverage test runner, but keeps track of what the original runner was so that the coverage runner can inherit from it. Then, call the test command. This plays well with apps that override the test command, such as South. """ - coverage_settings.ORIG_TEST_RUNNER = settings.TEST_RUNNER - settings.TEST_RUNNER = coverage_settings.COVERAGE_TEST_RUNNER - call_command('test', *test_labels, **options) - + if kwargs.get('with_coverage'): + coverage_settings.ORIG_TEST_RUNNER = settings.TEST_RUNNER + settings.TEST_RUNNER = coverage_settings.COVERAGE_TEST_RUNNER + super(Command, self).handle(*args, **kwargs) From fb997fed8ebd73f63f4159068963dcff06cf5b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:37:00 +0200 Subject: [PATCH 4/6] Add some docs about settings --- README.rst | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 29a3e3f..0485cf9 100644 --- a/README.rst +++ b/README.rst @@ -41,6 +41,23 @@ to. You can simply use the test runner if you like. See ``settings.py`` for more detail. 3. Run ``manage.py test`` like you normally do. +Settings +-------- + +All settings are prefixed with ``COVERAGE_``. + +* **TEST_RUNNER**: Specify the coverage test runner. Default is ``django_coverage.coverage_runner.CoverageRunner`` +* **USE_CACHE**: Specify whether coverage data file is created or not. Default is ``False``. +* **CODE_EXCLUDES**: List of regular expressions to exclude in coverage report. +* **PATH_EXCLUDES**: List of regular expressions of paths to exclude from coverage analysis. +* **ADDITIONNAL_MODULES**: Specify a list of additional module paths to include in the coverage analysis. +* **MODULE_EXCLUDES**: Specify a list of regular expressions of module paths to exclude from the coverage analysis. +* **REPORT_HTML_OUTPUT_DIR**: Directory where coverage report create it's report. +* **CUSTOM_REPORTS**: ``True``, for html reports by 55minutes, False for coverage.py. +* **USE_STDOUT**: ``True``, always output coverage reports to STDOUT. ``False`` don't. +* **BADGE_TYPE**: Badge type to create. Default is ``drone.io``. + +For more information about settings, read ``settings.py`` file. Extras ====== @@ -53,7 +70,7 @@ This will be stored in the same directory as the coverage report data: ``$PROJECT/.coverage/coverage_status.png``. Currently, the only badge type that is included is drone.io_. When other -types are included, you will be able to select which is used by +types are included, you will be able to select which is used by ``settings.COVERAGE_BADGE_TYPE``. To prevent the badge generation, you could set this to ``None``. From 335478107549a96d159b2b44585144458aee2424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:46:04 +0200 Subject: [PATCH 5/6] More readable --- README.rst | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/README.rst b/README.rst index 0485cf9..3d11a7e 100644 --- a/README.rst +++ b/README.rst @@ -46,16 +46,46 @@ Settings All settings are prefixed with ``COVERAGE_``. -* **TEST_RUNNER**: Specify the coverage test runner. Default is ``django_coverage.coverage_runner.CoverageRunner`` -* **USE_CACHE**: Specify whether coverage data file is created or not. Default is ``False``. -* **CODE_EXCLUDES**: List of regular expressions to exclude in coverage report. -* **PATH_EXCLUDES**: List of regular expressions of paths to exclude from coverage analysis. -* **ADDITIONNAL_MODULES**: Specify a list of additional module paths to include in the coverage analysis. -* **MODULE_EXCLUDES**: Specify a list of regular expressions of module paths to exclude from the coverage analysis. -* **REPORT_HTML_OUTPUT_DIR**: Directory where coverage report create it's report. -* **CUSTOM_REPORTS**: ``True``, for html reports by 55minutes, False for coverage.py. -* **USE_STDOUT**: ``True``, always output coverage reports to STDOUT. ``False`` don't. -* **BADGE_TYPE**: Badge type to create. Default is ``drone.io``. + +**TEST_RUNNER** + +Specify the coverage test runner. Default is ``django_coverage.coverage_runner.CoverageRunner`` + +**USE_CACHE** + +Specify whether coverage data file is created or not. Default is ``False``. + +**CODE_EXCLUDES** + +List of regular expressions to exclude in coverage report. + +**PATH_EXCLUDES** + +List of regular expressions of paths to exclude from coverage analysis. + +**ADDITIONNAL_MODULES** + +Specify a list of additional module paths to include in the coverage analysis. + +**MODULE_EXCLUDES** + +Specify a list of regular expressions of module paths to exclude from the coverage analysis. + +**REPORT_HTML_OUTPUT_DIR** + +Directory where coverage report create it's report. + +**CUSTOM_REPORTS** + +``True``, for html reports by 55minutes, False for coverage.py. + +**USE_STDOUT** + +``True``, always output coverage reports to STDOUT. ``False`` don't. + +**BADGE_TYPE** + +Badge type to create. Default is ``drone.io``. For more information about settings, read ``settings.py`` file. From 34a8c491bce021cb5e75003301a0fd9a35881c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20Leh=C3=A9e?= Date: Thu, 12 Jun 2014 17:46:56 +0200 Subject: [PATCH 6/6] Missing False statement --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 3d11a7e..78d6aca 100644 --- a/README.rst +++ b/README.rst @@ -77,7 +77,7 @@ Directory where coverage report create it's report. **CUSTOM_REPORTS** -``True``, for html reports by 55minutes, False for coverage.py. +``True``, for html reports by 55minutes, ``False`` for coverage.py. **USE_STDOUT**