diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-02-28 07:50:55 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-02-28 07:50:55 -0500 |
commit | 7f15dd95f5626eea58ca91172885eeaf019aed14 (patch) | |
tree | 9f21b08ad09fda11acc95ce02fd58c118f64ea7c | |
parent | 000f1c7d689ee0c85b7f08924512e332f4f1e509 (diff) | |
download | python-coveragepy-git-7f15dd95f5626eea58ca91172885eeaf019aed14.tar.gz |
Fix bug with \f in HTML report. #360.
-rw-r--r-- | CHANGES.txt | 5 | ||||
-rw-r--r-- | coverage/phystokens.py | 5 | ||||
-rw-r--r-- | tests/test_html.py | 10 |
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't this great?Ë!" 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.""" |