mirror of
https://github.com/jazzband/django-discover-jenkins.git
synced 2026-05-14 10:33:15 +00:00
Make excluding files really work
Exclude locations must be paths, and should not be an empty list, if don't want to exclude anything should be None.
This commit is contained in:
parent
d074b54b57
commit
6e237fd092
1 changed files with 12 additions and 25 deletions
|
|
@ -49,9 +49,9 @@ class CoverageTask(object):
|
|||
make_option(
|
||||
"--coverage-exclude",
|
||||
action="append",
|
||||
default=settings.COVERAGE_EXCLUDES,
|
||||
default=settings.COVERAGE_EXCLUDE_PATHS,
|
||||
dest="coverage_excludes",
|
||||
help="Module name to exclude"
|
||||
help="Paths to be excluded from coverage"
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -60,22 +60,7 @@ class CoverageTask(object):
|
|||
self.with_migrations = options['coverage_with_migrations']
|
||||
self.html_dir = options['coverage_html_report_dir']
|
||||
self.branch = options['coverage_measure_branch']
|
||||
|
||||
self.exclude_locations = []
|
||||
modnames = options['coverage_excludes']
|
||||
for modname in modnames:
|
||||
try:
|
||||
self.exclude_locations.append(
|
||||
os.path.dirname(
|
||||
import_module(modname).__file__
|
||||
)
|
||||
)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# Extra folders to exclude. Particularly useful to specify things like
|
||||
# apps/company/migrations/*
|
||||
self.exclude_locations.extend(settings.COVERAGE_EXCLUDES_FOLDERS)
|
||||
self.exclude_locations = options['coverage_excludes'] or None
|
||||
|
||||
self.coverage = coverage(
|
||||
branch=self.branch,
|
||||
|
|
@ -95,18 +80,20 @@ class CoverageTask(object):
|
|||
|
||||
if not os.path.exists(self.output_dir):
|
||||
os.makedirs(self.output_dir)
|
||||
self.coverage.xml_report(morfs=morfs,
|
||||
outfile=os.path.join(
|
||||
self.output_dir, 'coverage.xml'))
|
||||
|
||||
self.coverage.xml_report(
|
||||
morfs=morfs,
|
||||
outfile=os.path.join(self.output_dir, 'coverage.xml')
|
||||
)
|
||||
|
||||
if self.html_dir:
|
||||
self.coverage.html_report(morfs=morfs, directory=self.html_dir)
|
||||
self.coverage.html_report(
|
||||
morfs=morfs,
|
||||
directory=self.html_dir
|
||||
)
|
||||
|
||||
def want_file(self, filename):
|
||||
if not self.with_migrations and '/migrations/' in filename:
|
||||
return False
|
||||
for location in self.exclude_locations:
|
||||
if filename.startswith(location):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue