summaryrefslogtreecommitdiff
path: root/src/mailman/rest/tests/test_root.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/rest/tests/test_root.py
parenta1666479d87e26e5c79dd1cf507b8ef0472c59aa (diff)
downloadmailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.tar.gz
mailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.tar.zst
mailman-a9464c14fc6dfc23613a1ec89446393fe6476f88.zip
Diffstat (limited to 'src/mailman/rest/tests/test_root.py')
-rw-r--r--src/mailman/rest/tests/test_root.py32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py
index 90d30bd80..4a9ba0dd1 100644
--- a/src/mailman/rest/tests/test_root.py
+++ b/src/mailman/rest/tests/test_root.py
@@ -38,38 +38,25 @@ class TestSystem(unittest.TestCase):
def test_system_url_too_long(self):
# /system/foo/bar is not allowed.
- try:
- # For Python 2.6.
+ with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.0/system/foo/bar')
- except HTTPError as exc:
- self.assertEqual(exc.code, 400)
- else:
- raise AssertionError('Expected HTTPError')
+ self.assertEqual(cm.exception.code, 400)
def test_system_url_not_preferences(self):
# /system/foo where `foo` is not `preferences`.
- try:
- # For Python 2.6.
+ with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.0/system/foo')
- except HTTPError as exc:
- self.assertEqual(exc.code, 400)
- else:
- raise AssertionError('Expected HTTPError')
+ self.assertEqual(cm.exception.code, 400)
def test_system_preferences_are_read_only(self):
# /system/preferences are read-only.
- try:
- # For Python 2.6.
+ with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.0/system/preferences', {
'acknowledge_posts': True,
}, method='PATCH')
- except HTTPError as exc:
- self.assertEqual(exc.code, 405)
- else:
- raise AssertionError('Expected HTTPError')
+ self.assertEqual(cm.exception.code, 405)
# /system/preferences are read-only.
- try:
- # For Python 2.6.
+ with self.assertRaises(HTTPError) as cm:
call_api('http://localhost:9001/3.0/system/preferences', {
'acknowledge_posts': False,
'delivery_mode': 'regular',
@@ -79,7 +66,4 @@ class TestSystem(unittest.TestCase):
'receive_list_copy': True,
'receive_own_postings': True,
}, method='PUT')
- except HTTPError as exc:
- self.assertEqual(exc.code, 405)
- else:
- raise AssertionError('Expected HTTPError')
+ self.assertEqual(cm.exception.code, 405)