Merge pull request #2956 from Pylons/bugfix/httpexception__str__-1.7
(BP: 1.7) Bugfix: httpexception __str__
Backport of https://github.com/Pylons/pyramid/pull/2956
| | |
| | | .. _changes_1.7.4: |
| | | |
| | | Unreleased |
| | | ========== |
| | | |
| | | - HTTPException's accepts a detail kwarg that may be used to pass additional |
| | | details to the exception. You may now pass objects so long as they have a |
| | | valid __str__ method. See https://github.com/Pylons/pyramid/pull/2951 |
| | | |
| | | 1.7.4 (2017-01-24) |
| | | ================== |
| | | |
| | |
| | | del self.content_length |
| | | |
| | | def __str__(self): |
| | | return self.detail or self.explanation |
| | | return str(self.detail) if self.detail else self.explanation |
| | | |
| | | def _json_formatter(self, status, body, title, environ): |
| | | return {'message': body, |
| | |
| | | |
| | | from pyramid.compat import ( |
| | | bytes_, |
| | | string_types, |
| | | text_, |
| | | ) |
| | | |
| | |
| | | body = list(exc(environ, start_response))[0] |
| | | self.assertEqual(body, b'200 OK\n\n/La Pe\xc3\xb1a') |
| | | |
| | | def test_allow_detail_non_str(self): |
| | | exc = self._makeOne(detail={'error': 'This is a test'}) |
| | | self.assertIsInstance(exc.__str__(), string_types) |
| | | |
| | | |
| | | class TestRenderAllExceptionsWithoutArguments(unittest.TestCase): |
| | | def _doit(self, content_type): |
| | | from pyramid.httpexceptions import status_map |