diff options
| author | Tres Seaver <tseaver@palladion.com> | 2015-06-09 15:35:52 -0400 |
|---|---|---|
| committer | Tres Seaver <tseaver@palladion.com> | 2015-06-09 15:35:52 -0400 |
| commit | 2c3d653e0982eca137e58fe9ba0138469d862bf7 (patch) | |
| tree | 7b2a8b0f89cd10947520795ec6c1024deccc1411 | |
| parent | a4b674f0bddc5104b8d8b0e179f71ecd5e10336f (diff) | |
| parent | 7740b65e00a5581c431bbade68be0c471aeccb42 (diff) | |
| download | pyramid-2c3d653e0982eca137e58fe9ba0138469d862bf7.tar.gz pyramid-2c3d653e0982eca137e58fe9ba0138469d862bf7.tar.bz2 pyramid-2c3d653e0982eca137e58fe9ba0138469d862bf7.zip | |
Merge pull request #1836 from Pylons/fix-1832-master
Return concrete classes from 'pyramid.httpexceptions.exception_response'
| -rw-r--r-- | pyramid/httpexceptions.py | 16 | ||||
| -rw-r--r-- | pyramid/tests/test_httpexceptions.py | 13 |
2 files changed, 19 insertions, 10 deletions
diff --git a/pyramid/httpexceptions.py b/pyramid/httpexceptions.py index 465769834..93d06e0d6 100644 --- a/pyramid/httpexceptions.py +++ b/pyramid/httpexceptions.py @@ -562,10 +562,7 @@ class HTTPClientError(HTTPError): a bug. A server-side traceback is not warranted. Unless specialized, this is a '400 Bad Request' """ - code = 400 - title = 'Bad Request' - explanation = ('The server could not comply with the request since ' - 'it is either malformed or otherwise incorrect.') + pass class HTTPBadRequest(HTTPClientError): """ @@ -576,7 +573,10 @@ class HTTPBadRequest(HTTPClientError): code: 400, title: Bad Request """ - pass + code = 400 + title = 'Bad Request' + explanation = ('The server could not comply with the request since ' + 'it is either malformed or otherwise incorrect.') class HTTPUnauthorized(HTTPClientError): """ @@ -988,15 +988,15 @@ class HTTPServerError(HTTPError): This is an error condition in which the server is presumed to be in-error. Unless specialized, this is a '500 Internal Server Error'. """ + pass + +class HTTPInternalServerError(HTTPServerError): code = 500 title = 'Internal Server Error' explanation = ( 'The server has either erred or is incapable of performing ' 'the requested operation.') -class HTTPInternalServerError(HTTPServerError): - pass - class HTTPNotImplemented(HTTPServerError): """ subclass of :class:`~HTTPServerError` diff --git a/pyramid/tests/test_httpexceptions.py b/pyramid/tests/test_httpexceptions.py index d0779e080..c700dc80e 100644 --- a/pyramid/tests/test_httpexceptions.py +++ b/pyramid/tests/test_httpexceptions.py @@ -10,13 +10,22 @@ class Test_exception_response(unittest.TestCase): from pyramid.httpexceptions import exception_response return exception_response(*arg, **kw) + def test_status_400(self): + from pyramid.httpexceptions import HTTPBadRequest + self.assertTrue(isinstance(self._callFUT(400), HTTPBadRequest)) + def test_status_404(self): from pyramid.httpexceptions import HTTPNotFound - self.assertEqual(self._callFUT(404).__class__, HTTPNotFound) + self.assertTrue(isinstance(self._callFUT(404), HTTPNotFound)) + + def test_status_500(self): + from pyramid.httpexceptions import HTTPInternalServerError + self.assertTrue(isinstance(self._callFUT(500), + HTTPInternalServerError)) def test_status_201(self): from pyramid.httpexceptions import HTTPCreated - self.assertEqual(self._callFUT(201).__class__, HTTPCreated) + self.assertTrue(isinstance(self._callFUT(201), HTTPCreated)) def test_extra_kw(self): resp = self._callFUT(404, headers=[('abc', 'def')]) |
