Commits

Ned Batchelder committed d27dbdb

Don't trace code if the reported filename is *.html. Fixes issue #82.

Comments (0)

Files changed (2)

 - Doctest text files are no longer recorded in the coverage data, since they
   can't be reported anyway.  Fixes `issue 52`_ and `issue 61`_.
 
+- Jinja HTML templates compile into Python code using the HTML filename,
+  which confused coverage.py.  Now these files are no longer traced, fixing
+  `issue 82`.
+
 - Source files can have more than one dot in them (foo.test.py), and will be
   treated properly while reporting.  Fixes `issue 46`_.
 
 .. _issue 61: http://bitbucket.org/ned/coveragepy/issue/61/annotate-i-doesnt-work
 .. _issue 62: http://bitbucket.org/ned/coveragepy/issue/62
 .. _issue 59: http://bitbucket.org/ned/coveragepy/issue/59/html-report-fails-with-int-object-is
+.. _issue 82: http://bitbucket.org/ned/coveragepy/issue/82/tokenerror-when-generating-html-report
 
 
 Version 3.3.1 --- 6 March 2010

coverage/control.py

             # can't do anything with the data later anyway.
             return False
 
+        if filename.endswith(".html"):
+            # Jinja and maybe other templating systems compile templates into
+            # Python code, but use the template filename as the filename in
+            # the compiled code.  Of course, those filenames are useless later
+            # so don't bother collecting.  TODO: How should we really separate
+            # out good file extensions from bad?
+            return False
+
         self._check_for_packages()
 
         # Compiled Python files have two filenames: frame.f_code.co_filename is