summaryrefslogtreecommitdiff
path: root/src/mailman/app/tests/test_templates.py
diff options
context:
space:
mode:
authorBarry Warsaw2012-10-31 17:31:12 +0100
committerBarry Warsaw2012-10-31 17:31:12 +0100
commita9464c14fc6dfc23613a1ec89446393fe6476f88 (patch)
tree74a926cfe64066ebffcf9adb89e7672289173d84 /src/mailman/app/tests/test_templates.py
parenta1666479d87e26e5c79dd1cf507b8ef0472c59aa (diff)
downloadmailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.tar.gz
mailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.tar.zst
mailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.zip
Diffstat (limited to 'src/mailman/app/tests/test_templates.py')
-rw-r--r--src/mailman/app/tests/test_templates.py42
1 files changed, 12 insertions, 30 deletions
diff --git a/src/mailman/app/tests/test_templates.py b/src/mailman/app/tests/test_templates.py
index 6dfbd7109..788412a57 100644
--- a/src/mailman/app/tests/test_templates.py
+++ b/src/mailman/app/tests/test_templates.py
@@ -98,49 +98,31 @@ class TestTemplateLoader(unittest.TestCase):
self.assertEqual(content, 'Test content')
def test_uri_not_found(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///missing.txt')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'No such file')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'No such file')
def test_shorter_url_error(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'No template specified')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'No template specified')
def test_short_url_error(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman://')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'No template specified')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'No template specified')
def test_bad_language(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///xx/demo.txt')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'Bad language or list name')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'Bad language or list name')
def test_bad_mailing_list(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///missing@example.com/demo.txt')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'Bad language or list name')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'Bad language or list name')
def test_too_many_path_components(self):
- try:
+ with self.assertRaises(urllib2.URLError) as cm:
self._loader.get('mailman:///missing@example.com/en/foo/demo.txt')
- except urllib2.URLError as error:
- self.assertEqual(error.reason, 'No such file')
- else:
- raise AssertionError('Exception expected')
+ self.assertEqual(cm.exception.reason, 'No such file')