summaryrefslogtreecommitdiff
path: root/test/test_html.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-08-07 21:29:37 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-08-07 21:29:37 -0400
commit1728c47a79e17bdbc0889868f466a892881e8c82 (patch)
treec7f0b9afe1e85fed988ae70b9269f647998ae68b /test/test_html.py
parent8ecba376fabb6300e6ce2b71fa07737fde7cf7ab (diff)
parent6527a504c0871621563bb5d2b4147a065beaa55e (diff)
downloadpython-coveragepy-git-1728c47a79e17bdbc0889868f466a892881e8c82.tar.gz
Merged
Diffstat (limited to 'test/test_html.py')
-rw-r--r--test/test_html.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_html.py b/test/test_html.py
index c5c87d2a..1877a30d 100644
--- a/test/test_html.py
+++ b/test/test_html.py
@@ -195,3 +195,24 @@ 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.
+
+ """
+ if sys.version_info < (3, 0):
+ source = "exec compile('','','exec') in {'__file__': 'liar.html'}"
+ else:
+ source = "exec(compile('','','exec'), {'__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()
+ self.assert_exists("htmlcov/index.html")