summaryrefslogtreecommitdiff
path: root/test/test_html.py
diff options
context:
space:
mode:
authorJulian Berman <Julian+Hg@GrayVines.com>2012-07-31 10:17:00 -0400
committerJulian Berman <Julian+Hg@GrayVines.com>2012-07-31 10:17:00 -0400
commite4671e4ba2dd74204abd6a41ddb411f786c484cd (patch)
tree3eb1ea75877e62a97f2190e206b1d9b2be3edef6 /test/test_html.py
parent4b84b6b6035f7bdc44af395615f096419d5a5219 (diff)
downloadpython-coveragepy-e4671e4ba2dd74204abd6a41ddb411f786c484cd.tar.gz
Don't report coverage for non-Python source files even if __file__ says they were executed.
Closes #82
Diffstat (limited to 'test/test_html.py')
-rw-r--r--test/test_html.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/test_html.py b/test/test_html.py
index c5c87d2..96f98c8 100644
--- a/test/test_html.py
+++ b/test/test_html.py
@@ -195,3 +195,21 @@ class HtmlWithUnparsableFilesTest(CoverageTest):
self.make_file("innocuous.html", "<h1>This isn't python at all!</h1>")
output = self.run_command("coverage html")
self.assertEqual(output.strip(), "No data to report.")
+
+ def test_execed_liar_ignored(self):
+ """
+ Jinja2 sets __file__ to be a non-Python file, and then execs code.
+
+ If that file contains non-Python code, a TokenError shouldn't
+ have been raised when writing the HTML report.
+
+ """
+
+ source = "exec compile('', '', 'exec') in {'__file__' : 'liar.html'}"
+ self.make_file("liar.py", source)
+ self.make_file("liar.html", "{# Whoops, not python code #}")
+ cov = coverage.coverage()
+ cov.start()
+ self.import_local_file("liar")
+ cov.stop()
+ cov.html_report()