diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-12 17:17:38 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-06-12 17:17:38 -0400 |
commit | 44527cc9db62aa3979c69abe4edb7070aafd6897 (patch) | |
tree | eb0476b7b5cab892b8e122cb3e8291b5458763c8 /coverage/control.py | |
parent | be5178fda38750c0aae78061bf1b1bf3397a467d (diff) | |
download | python-coveragepy-git-44527cc9db62aa3979c69abe4edb7070aafd6897.tar.gz |
Hacked-in django template support
--HG--
branch : django
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/coverage/control.py b/coverage/control.py index 14f9b80e..a65a7153 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -18,6 +18,9 @@ from coverage.results import Analysis, Numbers from coverage.summary import SummaryReporter from coverage.xmlreport import XmlReporter +from coverage.django import DjangoTracer + + # Pypy has some unusual stuff in the "stdlib". Consider those locations # when deciding where the stdlib is. try: @@ -152,6 +155,8 @@ class coverage(object): coroutine=self.config.coroutine, ) + self.django_tracer = DjangoTracer() # should this be a class? Singleton... + # Suffixes are a bit tricky. We want to use the data suffix only when # collecting data, not when combining data. So we save it as # `self.run_suffix` now, and promote it to `self.data_suffix` if we @@ -277,6 +282,10 @@ class coverage(object): canonical = self.file_locator.canonical_filename(filename) + # DJANGO HACK + if self.django_tracer.should_trace(canonical): + return canonical, self.django_tracer + # If the user specified source or include, then that's authoritative # about the outer bound of what to measure and we don't have to apply # any canned exclusions. If they didn't, then we have to exclude the @@ -302,7 +311,7 @@ class coverage(object): if self.omit_match and self.omit_match.match(canonical): return None, "is inside an --omit pattern" - return canonical, "because we love you" + return canonical, None def _should_trace(self, filename, frame): """Decide whether to trace execution in `filename`. @@ -310,14 +319,15 @@ class coverage(object): Calls `_should_trace_with_reason`, and returns just the decision. """ - canonical, reason = self._should_trace_with_reason(filename, frame) + canonical, other = self._should_trace_with_reason(filename, frame) if self.debug.should('trace'): if not canonical: - msg = "Not tracing %r: %s" % (filename, reason) + msg = "Not tracing %r: %s" % (filename, other) + other = None else: msg = "Tracing %r" % (filename,) self.debug.write(msg) - return canonical + return canonical, other def _warn(self, msg): """Use `msg` as a warning.""" |