summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Anderson <sontek@gmail.com>2014-12-26 00:44:44 -0800
committerJohn Anderson <sontek@gmail.com>2014-12-26 00:44:44 -0800
commit367ffec92bd502075e0f2f827f4b9d9b3caea748 (patch)
treef5f69f41558787a532f298b12fa63aec7082c814
parent88c11a8f09d6e9749a705cb62caa945c496e84e9 (diff)
downloadpyramid-367ffec92bd502075e0f2f827f4b9d9b3caea748.tar.gz
pyramid-367ffec92bd502075e0f2f827f4b9d9b3caea748.tar.bz2
pyramid-367ffec92bd502075e0f2f827f4b9d9b3caea748.zip
Add test to show usage of custom response class
-rw-r--r--pyramid/tests/test_config/test_init.py30
1 files changed, 30 insertions, 0 deletions
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