From 043d07dee3992d3e7381a41c3ff716234e766a1c Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 29 Jan 2015 21:35:21 -0500 Subject: Add a disabled test that demonstrates bug #351. --- tests/test_html.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/test_html.py') diff --git a/tests/test_html.py b/tests/test_html.py index 5b76e36..7af695d 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -288,22 +288,30 @@ class HtmlWithUnparsableFilesTest(HtmlTestHelpers, CoverageTest): cov.html_report() self.assert_exists("htmlcov/index.html") - def test_decode_error(self): + # TODO: enable this test, and then fix this: + # https://bitbucket.org/ned/coveragepy/issue/351/files-with-incorrect-encoding-are-ignored + def SKIP_THIS_decode_error(self): # imp.load_module won't load a file with an undecodable character # in a comment, though Python will run them. So we'll change the # file after running. self.make_file("main.py", "import sub.not_ascii") self.make_file("sub/__init__.py") self.make_file("sub/not_ascii.py", """\ + # coding: utf8 a = 1 # Isn't this great?! """) cov = coverage.coverage() self.start_import_stop(cov, "main") - # Create the undecodable version of the file. - self.make_file("sub/not_ascii.py", """\ - a = 1 # Isn't this great?\xcb! - """) + # Create the undecodable version of the file. make_file is too helpful, + # so get down and dirty with bytes. + with open("sub/not_ascii.py", "wb") as f: + f.write(b"# coding: utf8\na = 1 # Isn't this great?\xcb!\n") + + with open("sub/not_ascii.py", "rb") as f: + undecodable = f.read() + self.assertIn(b"?\xcb!", undecodable) + cov.html_report() html_report = self.get_html_report_content("sub/not_ascii.py") -- cgit v1.2.1