summaryrefslogtreecommitdiff
path: root/src/mailman/app/tests/test_templates.py
diff options
context:
space:
mode:
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')