diff options
Diffstat (limited to 'src/mailman/app/tests/test_templates.py')
| -rw-r--r-- | src/mailman/app/tests/test_templates.py | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/src/mailman/app/tests/test_templates.py b/src/mailman/app/tests/test_templates.py index afde68647..68bab9f49 100644 --- a/src/mailman/app/tests/test_templates.py +++ b/src/mailman/app/tests/test_templates.py @@ -17,27 +17,24 @@ """Test the template downloader API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestTemplateLoader', ] import os +import six import shutil -import urllib2 import tempfile import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.templates import ITemplateLoader from mailman.testing.layers import ConfigLayer +from six.moves.urllib_error import URLError +from zope.component import getUtility @@ -98,32 +95,32 @@ class TestTemplateLoader(unittest.TestCase): self.assertEqual(content, 'Test content') def test_uri_not_found(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman:///missing.txt') self.assertEqual(cm.exception.reason, 'No such file') def test_shorter_url_error(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman:///') self.assertEqual(cm.exception.reason, 'No template specified') def test_short_url_error(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman://') self.assertEqual(cm.exception.reason, 'No template specified') def test_bad_language(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman:///xx/demo.txt') self.assertEqual(cm.exception.reason, 'Bad language or list name') def test_bad_mailing_list(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman:///missing@example.com/demo.txt') self.assertEqual(cm.exception.reason, 'Bad language or list name') def test_too_many_path_components(self): - with self.assertRaises(urllib2.URLError) as cm: + with self.assertRaises(URLError) as cm: self._loader.get('mailman:///missing@example.com/en/foo/demo.txt') self.assertEqual(cm.exception.reason, 'No such file') @@ -132,8 +129,8 @@ class TestTemplateLoader(unittest.TestCase): test_text = b'\xe4\xb8\xad' path = os.path.join(self.var_dir, 'templates', 'site', 'it') os.makedirs(path) - with open(os.path.join(path, 'demo.txt'), 'w') as fp: - print(test_text, end='', file=fp) + with open(os.path.join(path, 'demo.txt'), 'wb') as fp: + fp.write(test_text) content = self._loader.get('mailman:///it/demo.txt') - self.assertTrue(isinstance(content, unicode)) + self.assertIsInstance(content, six.text_type) self.assertEqual(content, test_text.decode('utf-8')) |
