Chris McDonough
2011-06-20 4275ebb943e5549ceb51577b2e5b1ae7a3ee5b20
- Copy exception templates from webob.exc into pyramid.httpexceptions and
ensure they all work.
2 files modified
33 ■■■■ changed files
TODO.txt 3 ●●●●● patch | view | raw | blame | history
pyramid/tests/test_httpexceptions.py 30 ●●●●● patch | view | raw | blame | history
TODO.txt
@@ -6,9 +6,6 @@
- Grep for IExceptionResponse, forgot what it does.
- Copy exception templates from webob.exc into pyramid.httpexceptions and
  ensure they all work.
- Docs mention ``exception.args[0]`` as a way to get messages; check that
  this works.
pyramid/tests/test_httpexceptions.py
@@ -278,6 +278,19 @@
        exc = self._makeOne(location='foo')
        self.assertEqual(exc.location, 'foo')
    def test_it_location_firstarg(self):
        exc = self._makeOne('foo')
        self.assertEqual(exc.location, 'foo')
    def test_it_call_with_default_body_tmpl(self):
        exc = self._makeOne(location='foo')
        environ = _makeEnviron()
        start_response = DummyStartResponse()
        app_iter = exc(environ, start_response)
        self.assertEqual(app_iter[0],
                         ('None None\n\nThe resource has been moved to foo; '
                          'you should be redirected automatically.\n\n'))
class TestHTTPForbidden(unittest.TestCase):
    def _makeOne(self, *arg, **kw):
        from pyramid.httpexceptions import HTTPForbidden
@@ -290,7 +303,22 @@
    def test_it_result_passed(self):
        exc = self._makeOne(result='foo')
        self.assertEqual(exc.result, 'foo')
class TestHTTPMethodNotAllowed(unittest.TestCase):
    def _makeOne(self, *arg, **kw):
        from pyramid.httpexceptions import HTTPMethodNotAllowed
        return HTTPMethodNotAllowed(*arg, **kw)
    def test_it_with_default_body_tmpl(self):
        exc = self._makeOne()
        environ = _makeEnviron()
        start_response = DummyStartResponse()
        app_iter = exc(environ, start_response)
        self.assertEqual(app_iter[0],
                         ('405 Method Not Allowed\n\nThe method GET is not '
                          'allowed for this resource. \n\n\n'))
class DummyRequest(object):
    exception = None