From 367ffec92bd502075e0f2f827f4b9d9b3caea748 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Fri, 26 Dec 2014 00:44:44 -0800 Subject: Add test to show usage of custom response class --- pyramid/tests/test_config/test_init.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py index 1e58e4d0f..c9eaf7c27 100644 --- a/pyramid/tests/test_config/test_init.py +++ b/pyramid/tests/test_config/test_init.py @@ -546,6 +546,36 @@ class ConfiguratorTests(unittest.TestCase): utility = reg.getUtility(IRequestFactory) self.assertEqual(utility, factory) + def test_setup_registry_request_factory_custom_response_class(self): + from pyramid.registry import Registry + from pyramid.interfaces import IRequestFactory + from pyramid.request import Request + + class MyResponse(object): + pass + + class MyRequest(Request): + ResponseClass = MyResponse + + reg = Registry() + config = self._makeOne(reg) + factory = MyRequest({ + 'PATH_INFO': '/', + 'wsgi.url_scheme': 'http', + 'HTTP_HOST': 'localhost', + 'SERVER_PROTOCOL': '1.0', + }) + factory.registry = reg + + config.setup_registry(request_factory=factory) + self.assertEqual(reg.queryUtility(IRequestFactory), None) + config.commit() + utility = reg.getUtility(IRequestFactory) + self.assertEqual(utility, factory) + + new_response = factory.response + self.assertTrue(isinstance(new_response, MyResponse)) + def test_setup_registry_request_factory_dottedname(self): from pyramid.registry import Registry from pyramid.interfaces import IRequestFactory -- cgit v1.2.3