diff options
| author | Aurélien Bompard | 2013-10-21 16:00:59 +0200 |
|---|---|---|
| committer | Aurélien Bompard | 2013-10-21 16:00:59 +0200 |
| commit | a2687bb2f937410a5e16185745e315e94fa03d9e (patch) | |
| tree | d45bb8032a5dfbc44e2d4fc28ba751ea5a888447 /src/mailman/utilities/tests/test_import.py | |
| parent | e3f8ad0d49104964ab14a9dfd0d60253d7d808c3 (diff) | |
| download | mailman-a2687bb2f937410a5e16185745e315e94fa03d9e.tar.gz mailman-a2687bb2f937410a5e16185745e315e94fa03d9e.tar.zst mailman-a2687bb2f937410a5e16185745e315e94fa03d9e.zip | |
Diffstat (limited to 'src/mailman/utilities/tests/test_import.py')
| -rw-r--r-- | src/mailman/utilities/tests/test_import.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py index bf757ba4b..f3e01c1a6 100644 --- a/src/mailman/utilities/tests/test_import.py +++ b/src/mailman/utilities/tests/test_import.py @@ -25,11 +25,13 @@ __all__ = [ ] +import os import cPickle import unittest from datetime import timedelta, datetime from traceback import format_exc +from mailman.config import config from mailman.app.lifecycle import create_list, remove_list from mailman.testing.layers import ConfigLayer from mailman.utilities.importer import import_config_pck, Import21Error @@ -515,6 +517,7 @@ class TestConvertToURI(unittest.TestCase): "Default value was not preserved for %s" % newvar) def test_unicode(self): + # non-ascii templates for oldvar in self._conf_mapping: self._pckdict[str(oldvar)] = b"Ol\xe1!" try: @@ -525,10 +528,24 @@ class TestConvertToURI(unittest.TestCase): for oldvar, newvar in self._conf_mapping.iteritems(): newattr = getattr(self._mlist, newvar) text = decorate(self._mlist, newattr) - expected = u'Ol\ufffd!'.encode("utf-8") - # we get bytestrings because the text is stored in a file + expected = u'Ol\ufffd!' self.assertEqual(text, expected) + def test_unicode_in_default(self): + # What if the default template is already in UTF-8? (like if you import twice) + footer = b'\xe4\xb8\xad $listinfo_uri' + footer_path = os.path.join(config.VAR_DIR, "templates", "lists", + "blank@example.com", "en", "footer-generic.txt") + try: + os.makedirs(os.path.dirname(footer_path)) + except OSError: + pass + with open(footer_path, "w") as footer_file: + footer_file.write(footer) + self._pckdict[b"msg_footer"] = b"NEW-VALUE" + import_config_pck(self._mlist, self._pckdict) + text = decorate(self._mlist, self._mlist.footer_uri) + self.assertEqual(text, 'NEW-VALUE') class TestRosterImport(unittest.TestCase): |
