summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorErick Wilder <erickwilder@gmail.com>2015-09-09 19:04:06 -0300
committerErick Wilder <erickwilder@gmail.com>2015-09-09 19:04:06 -0300
commit55af2c583a71ad3999b3cb9c856ba274a52163a4 (patch)
treee7c216833d2100a852385ac1effc9679032335c8 /tests
parent6a4fbbd98d885030a4b9fb41c53329ed7ce759d0 (diff)
parent424ea406381c775aff5abdd89c444b503c547d87 (diff)
downloadbabel-55af2c583a71ad3999b3cb9c856ba274a52163a4.tar.gz
Merge pull request #199 from lepistone/allow-utf8-bom-with-magic-comment
allow utf8 BOM + magic comment, closes #189
Diffstat (limited to 'tests')
-rw-r--r--tests/messages/test_extract.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/messages/test_extract.py b/tests/messages/test_extract.py
index 62c7227..ded697f 100644
--- a/tests/messages/test_extract.py
+++ b/tests/messages/test_extract.py
@@ -343,6 +343,23 @@ msg = _('Bonjour à tous')
self.assertEqual(u'Bonjour à tous', messages[0][2])
self.assertEqual([u'NOTE: hello'], messages[0][3])
+ def test_utf8_message_with_utf8_bom_and_magic_comment(self):
+ buf = BytesIO(codecs.BOM_UTF8 + u"""# -*- coding: utf-8 -*-
+# NOTE: hello
+msg = _('Bonjour à tous')
+""".encode('utf-8'))
+ messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
+ self.assertEqual(u'Bonjour à tous', messages[0][2])
+ self.assertEqual([u'NOTE: hello'], messages[0][3])
+
+ def test_utf8_bom_with_latin_magic_comment_fails(self):
+ buf = BytesIO(codecs.BOM_UTF8 + u"""# -*- coding: latin-1 -*-
+# NOTE: hello
+msg = _('Bonjour à tous')
+""".encode('utf-8'))
+ self.assertRaises(SyntaxError, list,
+ extract.extract_python(buf, ('_',), ['NOTE:'], {}))
+
def test_utf8_raw_strings_match_unicode_strings(self):
buf = BytesIO(codecs.BOM_UTF8 + u"""
msg = _('Bonjour à tous')