diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-29 21:35:21 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-01-29 21:35:21 -0500 |
commit | cab3262dd815c454e8db967f97afce8a4b071d4c (patch) | |
tree | a37166b9d9fb3cb9799af36a0c837989de2170f3 | |
parent | 068bbc3a6678ca4e4bb99d6b7178c67f4e258ddb (diff) | |
download | python-coveragepy-git-cab3262dd815c454e8db967f97afce8a4b071d4c.tar.gz |
Add a disabled test that demonstrates bug #351.
-rw-r--r-- | tests/test_html.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/test_html.py b/tests/test_html.py index 5b76e36b..7af695de 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") |