diff options
| author | Barry Warsaw | 2012-10-31 17:37:22 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2012-10-31 17:37:22 +0100 |
| commit | e60c151e0148c2f53eabe883f5921378ca6a845c (patch) | |
| tree | 74a926cfe64066ebffcf9adb89e7672289173d84 /src/mailman/rest/tests/test_root.py | |
| parent | a1666479d87e26e5c79dd1cf507b8ef0472c59aa (diff) | |
| parent | a9464c14fc6dfc23613a1ec89446393fe6476f88 (diff) | |
| download | mailman-e60c151e0148c2f53eabe883f5921378ca6a845c.tar.gz mailman-e60c151e0148c2f53eabe883f5921378ca6a845c.tar.zst mailman-e60c151e0148c2f53eabe883f5921378ca6a845c.zip | |
Diffstat (limited to 'src/mailman/rest/tests/test_root.py')
| -rw-r--r-- | src/mailman/rest/tests/test_root.py | 32 |
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) |
