Commits

Mikhail Korobov committed 7eef3da

Defaults for all settings

Comments (0)

Files changed (3)

coverage_runner.py

 
 import coverage, os, sys
 
-from django.conf import settings
+from django_coverage import settings
 from django.db.models import get_app, get_apps
 from django.test.simple import run_tests as base_run_tests
 
     run.
     """
     coverage.use_cache(0)
-    for e in getattr(settings, 'COVERAGE_CODE_EXCLUDES', []):
+    for e in settings.COVERAGE_CODE_EXCLUDES:
         coverage.exclude(e)
     coverage.start()
     results = base_run_tests(test_labels, verbosity, interactive, extra_tests)
         for app in get_apps():
             coverage_modules.append(_get_app_package(app))
 
-    coverage_modules.extend(getattr(settings, 'COVERAGE_ADDITIONAL_MODULES', []))
+    coverage_modules.extend(settings.COVERAGE_ADDITIONAL_MODULES)
 
     packages, modules, excludes, errors = get_all_modules(
-        coverage_modules, getattr(settings, 'COVERAGE_MODULE_EXCLUDES', []),
-        getattr(settings, 'COVERAGE_PATH_EXCLUDES', []))
+        coverage_modules, settings.COVERAGE_MODULE_EXCLUDES,
+        settings.COVERAGE_PATH_EXCLUDES)
 
     coverage.report(modules.values(), show_missing=1)
     if excludes:
             print >>sys.stderr, e,
         print >>sys.stdout
 
-    outdir = getattr(settings, 'COVERAGE_REPORT_HTML_OUTPUT_DIR', 'test_html')
+    outdir = settings.COVERAGE_REPORT_HTML_OUTPUT_DIR
     outdir = os.path.abspath(outdir)
     html_report(outdir, modules, excludes, errors)
     print >>sys.stdout

management/commands/test_coverage.py

     requires_model_validation = False
 
     def handle(self, *test_labels, **options):
-        from django.conf import settings
+        from django_coverage import settings
 
         verbosity = int(options.get('verbosity', 1))
         interactive = options.get('interactive', True)
 limitations under the License.
 """
 
+from django.conf import settings
+
 # Specify the coverage test runner
-COVERAGE_TEST_RUNNER = 'django_coverage.coverage_runner.run_tests'
+COVERAGE_TEST_RUNNER = getattr(settings, 'COVERAGE_TEST_RUNNER',
+                               'django_coverage.coverage_runner.run_tests')
 
 # Specify regular expressions of code blocks the coverage analyzer should
 # ignore as statements (e.g. ``raise NotImplemented``).
 # These statements are not figured in as part of the coverage statistics.
 # This setting is optional.
-COVERAGE_CODE_EXCLUDES = [
-    'def __unicode__\(self\):', 'def get_absolute_url\(self\):',
-    'from .* import .*', 'import .*',
-    ]
+
+COVERAGE_CODE_EXCLUDES = getattr(settings, 'COVERAGE_CODE_EXCLUDES',[
+                                    'def __unicode__\(self\):',
+                                    'def get_absolute_url\(self\):',
+                                    'from .* import .*', 'import .*',
+                                 ])
 
 # Specify a list of regular expressions of paths to exclude from
 # coverage analysis.
 # TODO: THE SETTING FOR MODULES
 # Use this to exclude subdirectories like ``r'.svn'``, for example.
 # This setting is optional.
-COVERAGE_PATH_EXCLUDES = [r'.svn']
+COVERAGE_PATH_EXCLUDES = getattr(settings, 'COVERAGE_PATH_EXCLUDES',
+                                 [r'.svn', 'migrations'])
 
 # Specify a list of additional module paths to include
 # in the coverage analysis. By default, only modules within installed
 # Note this list is *NOT* regular expression, so you have to be explicit,
 # such as 'myproject.utils', and not 'utils$'.
 # This setting is optional.
-COVERAGE_ADDITIONAL_MODULES = []
+COVERAGE_ADDITIONAL_MODULES = getattr(settings, 'COVERAGE_ADDITIONAL_MODULES', [])
 
 # Specify a list of regular expressions of module paths to exclude
 # from the coverage analysis. Examples are ``'tests$'`` and ``'urls$'``.
 # This setting is optional.
-COVERAGE_MODULE_EXCLUDES = ['tests$', 'settings$','urls$', 'common.views.test',
-                            '__init__', 'django']
+COVERAGE_MODULE_EXCLUDES = getattr(settings, 'COVERAGE_MODULE_EXCLUDES',
+                                   ['tests$', 'settings$', 'urls$',
+                                    'common.views.test', '__init__', 'django'])
+
 
 # Specify the directory where you would like the coverage report to create
 # the HTML files.
 # You'll need to make sure this directory exists and is writable by the
 # user account running the test.
 # You should probably set this one explicitly in your own settings file.
-COVERAGE_REPORT_HTML_OUTPUT_DIR = '/my_home/test_html'
 
+#COVERAGE_REPORT_HTML_OUTPUT_DIR = '/my_home/test_html'
+COVERAGE_REPORT_HTML_OUTPUT_DIR = getattr(settings,
+                                          'COVERAGE_REPORT_HTML_OUTPUT_DIR',
+                                          None)
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.