Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test with non-unicode text file #82

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion django_coverage_plugin/plugin.py
Expand Up @@ -145,7 +145,7 @@ def read_template_source(filename):
charset = 'utf-8'
else:
charset = settings.FILE_CHARSET
text = f.read().decode(charset)
text = f.read().decode(charset, errors='backslashreplace')

return text

Expand Down
8 changes: 8 additions & 0 deletions tests/test_simple.py
Expand Up @@ -262,3 +262,11 @@ def test_with_branch_enabled(self):
)
self.assertEqual(text, 'Hello\nWorld\n\nGoodbye')
self.assert_analysis([1, 2, 3, 4])


class TestNonUTF8StaticFile(DjangoPluginTestCase):
def test_non_utf8_static_file(self):
# Non-template file containing a word encoded in CP-1252
self.make_file("static/german.txt", bytes=b"sh\xf6n")
self.run_django_coverage(text='Hello')
self.assertEqual(self.get_html_report('../static/german.txt'), 0)