summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.txt5
-rw-r--r--coverage/phystokens.py5
-rw-r--r--tests/test_html.py10
3 files changed, 19 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index cab00a94..45c279c1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,7 +9,12 @@ Latest
- Branch coverage couldn't properly handle certain extremely long files. This
is now fixed (`issue 359`_).
+- HTML reports were truncated at formfeed characters. This is now fixed
+ (`issue 360`_). It's always fun when the problem is due to a `bug in the
+ Python standard library <http://bugs.python.org/issue19035>`_.
+
.. _issue 359: https://bitbucket.org/ned/coveragepy/issue/359/xml-report-chunk-error
+.. _issue 360: https://bitbucket.org/ned/coveragepy/issue/360/html-reports-get-confused-by-l-in-the-code
Version 4.0a5 --- 16 February 2015
diff --git a/coverage/phystokens.py b/coverage/phystokens.py
index b3b08704..ed6bd238 100644
--- a/coverage/phystokens.py
+++ b/coverage/phystokens.py
@@ -85,8 +85,11 @@ def source_token_lines(source):
ws_tokens = set([token.INDENT, token.DEDENT, token.NEWLINE, tokenize.NL])
line = []
col = 0
- source = source.expandtabs(8).replace('\r\n', '\n')
+
+ # The \f is because of http://bugs.python.org/issue19035
+ source = source.expandtabs(8).replace('\r\n', '\n').replace('\f', ' ')
tokgen = generate_tokens(source)
+
for ttype, ttext, (_, scol), (_, ecol), _ in phys_tokens(tokgen):
mark_start = True
for part in re.split('(\n)', ttext):
diff --git a/tests/test_html.py b/tests/test_html.py
index 6b398c43..004ebbfb 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -322,6 +322,16 @@ class HtmlWithUnparsableFilesTest(HtmlTestHelpers, CoverageTest):
expected = "# Isn&#39;t this great?&#203;!"
self.assertIn(expected, html_report)
+ def test_formfeeds(self):
+ # https://bitbucket.org/ned/coveragepy/issue/360/html-reports-get-confused-by-l-in-the-code
+ self.make_file("formfeed.py", "line_one = 1\n\f\nline_two = 2\n")
+ cov = coverage.coverage()
+ self.start_import_stop(cov, "formfeed")
+ cov.html_report()
+
+ formfeed_html = self.get_html_report_content("formfeed.py")
+ self.assertIn("line_two", formfeed_html)
+
class HtmlTest(CoverageTest):
"""Moar HTML tests."""