linter: Fix UnicodeError when parsing comments

And add tests when reading non-ASCII strings and comments (both from
Python strings and from files).

Fixes: #10
This commit is contained in:
Adrien Vergé
2016-06-28 09:58:23 +02:00
parent 63dd8313f8
commit c8ba8f7e99
4 changed files with 43 additions and 3 deletions

View File

@@ -44,3 +44,15 @@ class LinterTestCase(unittest.TestCase):
def test_run_on_list(self):
self.assertRaises(TypeError, linter.run,
['h', 'e', 'l', 'l', 'o'], self.fake_config())
def test_run_on_non_ascii_chars(self):
s = (u'- hétérogénéité\n'
u'# 19.99 €\n')
linter.run(s, self.fake_config())
linter.run(s.encode('utf-8'), self.fake_config())
linter.run(s.encode('iso-8859-15'), self.fake_config())
s = (u'- お早う御座います。\n'
u'# الأَبْجَدِيَّة العَرَبِيَّة\n')
linter.run(s, self.fake_config())
linter.run(s.encode('utf-8'), self.fake_config())