diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-21 19:14:42 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-21 19:14:42 -0500 |
commit | 83b72519760d669c8b2f15fdae2056000ba8e136 (patch) | |
tree | ed268cc1167441869d563efa0ebd3b81d5e8723d /test/test_html.py | |
parent | e004cc892cb624db29814811e3d9a2f3f4ca9908 (diff) | |
download | python-coveragepy-git-83b72519760d669c8b2f15fdae2056000ba8e136.tar.gz |
Trying to reproduce the latest incarnation of #82
Diffstat (limited to 'test/test_html.py')
-rw-r--r-- | test/test_html.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/test_html.py b/test/test_html.py index d33dd1f3..633b506b 100644 --- a/test/test_html.py +++ b/test/test_html.py @@ -253,6 +253,18 @@ class HtmlWithUnparsableFilesTest(CoverageTest): output = self.run_command("coverage html") self.assertEqual(output.strip(), "No data to report.") + def test_dothtml_not_python_indentation_error(self): + # We run a .html file, and when reporting, we can't parse it as + # Python. Since it wasn't .py, no error is reported. + + # Run an "html" file + self.make_file("innocuous.html", "a = 1") + self.run_command("coverage run innocuous.html") + # Before reporting, change it to be an indentation error. + self.make_file("innocuous.html", " hello\n bye\n") + 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 @@ -269,3 +281,20 @@ class HtmlWithUnparsableFilesTest(CoverageTest): cov.stop() cov.html_report() self.assert_exists("htmlcov/index.html") + + def test_execed_liar_ignored_indentation_error(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.jinja2'}" + else: + source = "exec(compile('','','exec'), {'__file__': 'liar.jinja2'})" + self.make_file("liar.py", source) + self.make_file("liar.jinja2", " hello\n bye\n") + cov = coverage.coverage() + cov.start() + self.import_local_file("liar") + cov.stop() + cov.html_report() + self.assert_exists("htmlcov/index.html") |