~abompard/mailman/mailman-templates-utf8

« back to all changes in this revision

Viewing changes to src/mailman/utilities/tests/test_templates.py

  • Committer: Aurélien Bompard
  • Date: 2015-02-11 15:00:52 UTC
  • Revision ID: aurelien@bompard.org-20150211150052-u99erqha5ikzvl8n
Assume templates are UTF-8

As discussed on the mailing-list:
https://mail.python.org/pipermail/mailman-developers/2013-October/023347.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
 
27
27
import os
 
28
import locale
28
29
import shutil
29
30
import tempfile
30
31
import unittest
227
228
            find('missing.txt', self.mlist)
228
229
        self.assertEqual(cm.exception.template_file, 'missing.txt')
229
230
 
 
231
    def test_encoding(self):
 
232
        with open(self.xxsite, 'w') as fp:
 
233
            fp.write('Ol\ufffd!')
 
234
        locale.setlocale(locale.LC_ALL, 'C')
 
235
        filename, self.fp = find('site.txt', language='xx')
 
236
        try:
 
237
            content = self.fp.read()
 
238
        except UnicodeDecodeError:
 
239
            self.fail("Templates should be considered UTF-8 by default")
 
240
        finally:
 
241
            locale.resetlocale(locale.LC_ALL)
 
242
        self.assertEqual(content, 'Ol\ufffd!')
 
243
 
230
244
 
231
245
 
232
246
class TestMake(unittest.TestCase):