~abompard/mailman/import21

« back to all changes in this revision

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

  • Committer: Aurélien Bompard
  • Date: 2013-10-21 14:00:59 UTC
  • Revision ID: aurelien@bompard.org-20131021140059-elbn007c58vp89q1
Text templates should be in UTF-8

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        with self.assertRaises(urllib2.URLError) as cm:
127
127
            self._loader.get('mailman:///missing@example.com/en/foo/demo.txt')
128
128
        self.assertEqual(cm.exception.reason, 'No such file')
 
129
 
 
130
    def test_non_ascii(self):
 
131
        # mailman://demo.txt with non-ascii content
 
132
        test_text = b'\xe4\xb8\xad'
 
133
        path = os.path.join(self.var_dir, 'templates', 'site', 'it')
 
134
        os.makedirs(path)
 
135
        with open(os.path.join(path, 'demo.txt'), 'w') as fp:
 
136
            print(test_text, end='', file=fp)
 
137
        content = self._loader.get('mailman:///it/demo.txt')
 
138
        self.assertTrue(isinstance(content, unicode))
 
139
        self.assertEqual(content, test_text.decode("utf-8"))