diff options
| author | Bert JW Regeer <bertjw@regeer.org> | 2013-09-05 21:58:44 -0600 |
|---|---|---|
| committer | Bert JW Regeer <bertjw@regeer.org> | 2013-09-05 22:01:10 -0600 |
| commit | 5fc89304910fb3bdacae8674c71ae37843f2d001 (patch) | |
| tree | 17e3fefbc94341f9d1dc016e7a1db5256ca056c3 | |
| parent | b368d7d88518226a3a55f0f31e96be7c57e01bc8 (diff) | |
| download | pyramid-5fc89304910fb3bdacae8674c71ae37843f2d001.tar.gz pyramid-5fc89304910fb3bdacae8674c71ae37843f2d001.tar.bz2 pyramid-5fc89304910fb3bdacae8674c71ae37843f2d001.zip | |
Re-enable two tests using JSON renderer instead of Chameleon
| -rw-r--r-- | pyramid/tests/test_config/test_views.py | 95 |
1 files changed, 50 insertions, 45 deletions
diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py index 02afc38cd..876145b8a 100644 --- a/pyramid/tests/test_config/test_views.py +++ b/pyramid/tests/test_config/test_views.py @@ -1842,45 +1842,47 @@ class TestViewsConfigurationMixin(unittest.TestCase): result = view(None, request) self.assertEqual(result.location, '/scriptname/foo/?a=1&b=2') -# def test_add_notfound_view_with_renderer(self): -# from zope.interface import implementedBy -# from pyramid.interfaces import IRequest -# from pyramid.httpexceptions import HTTPNotFound -# config = self._makeOne(autocommit=True) -# view = lambda *arg: {} -# config.add_notfound_view( -# view, -# renderer='pyramid.tests.test_config:files/minimal.pt') -# config.begin() -# try: # chameleon depends on being able to find a threadlocal registry -# request = self._makeRequest(config) -# view = self._getViewCallable(config, -# ctx_iface=implementedBy(HTTPNotFound), -# request_iface=IRequest) -# result = view(None, request) -# finally: -# config.end() -# self.assertTrue(b'div' in result.body) -# -# def test_add_forbidden_view_with_renderer(self): -# from zope.interface import implementedBy -# from pyramid.interfaces import IRequest -# from pyramid.httpexceptions import HTTPForbidden -# config = self._makeOne(autocommit=True) -# view = lambda *arg: {} -# config.add_forbidden_view( -# view, -# renderer='pyramid.tests.test_config:files/minimal.pt') -# config.begin() -# try: # chameleon requires a threadlocal registry -# request = self._makeRequest(config) -# view = self._getViewCallable(config, -# ctx_iface=implementedBy(HTTPForbidden), -# request_iface=IRequest) -# result = view(None, request) -# finally: -# config.end() -# self.assertTrue(b'div' in result.body) + def test_add_notfound_view_with_renderer(self): + from zope.interface import implementedBy + from pyramid.interfaces import IRequest + from pyramid.httpexceptions import HTTPNotFound + config = self._makeOne(autocommit=True) + view = lambda *arg: {} + config.introspection = False + config.add_notfound_view( + view, + renderer='json') + config.begin() + try: # chameleon depends on being able to find a threadlocal registry + request = self._makeRequest(config) + view = self._getViewCallable(config, + ctx_iface=implementedBy(HTTPNotFound), + request_iface=IRequest) + result = view(None, request) + finally: + config.end() + self.assertEqual("{}", result.body) + + def test_add_forbidden_view_with_renderer(self): + from zope.interface import implementedBy + from pyramid.interfaces import IRequest + from pyramid.httpexceptions import HTTPForbidden + config = self._makeOne(autocommit=True) + view = lambda *arg: {} + config.introspection = False + config.add_forbidden_view( + view, + renderer='json') + config.begin() + try: # chameleon requires a threadlocal registry + request = self._makeRequest(config) + view = self._getViewCallable(config, + ctx_iface=implementedBy(HTTPForbidden), + request_iface=IRequest) + result = view(None, request) + finally: + config.end() + self.assertEqual("{}", result.body) def test_set_view_mapper(self): from pyramid.interfaces import IViewMapperFactory @@ -3847,9 +3849,18 @@ class Test_view_description(unittest.TestCase): class DummyRegistry: pass +from zope.interface import implementer +from pyramid.interfaces import IResponse +@implementer(IResponse) +class DummyResponse(object): + content_type = None + default_content_type = None + class DummyRequest: subpath = () matchdict = None + response = DummyResponse() + def __init__(self, environ=None): if environ is None: environ = {} @@ -3860,12 +3871,6 @@ class DummyRequest: class DummyContext: pass -from zope.interface import implementer -from pyramid.interfaces import IResponse -@implementer(IResponse) -class DummyResponse(object): - pass - class DummyAccept(object): def __init__(self, *matches): self.matches = list(matches) |
