summaryrefslogtreecommitdiff
path: root/repoze/bfg/tests/test_scripting.py
diff options
context:
space:
mode:
authorChris McDonough <chrism@agendaless.com>2010-07-24 07:04:49 +0000
committerChris McDonough <chrism@agendaless.com>2010-07-24 07:04:49 +0000
commit81a833da2adff04d11b9228406bbc1528be65c64 (patch)
tree736765ad3018e4b9e432b4af4bb923fdbdcc898f /repoze/bfg/tests/test_scripting.py
parent8e18ea4a560b4456ace86bdef6060304de053238 (diff)
downloadpyramid-81a833da2adff04d11b9228406bbc1528be65c64.tar.gz
pyramid-81a833da2adff04d11b9228406bbc1528be65c64.tar.bz2
pyramid-81a833da2adff04d11b9228406bbc1528be65c64.zip
- A new method of the ``Configurator`` exists:
``set_request_factory``. If used, this method will set the factory used by the :mod:`repoze.bfg` router to create all request objects. - The ``Configurator`` constructor takes an additional argument: ``request_factory``. If used, this argument will set the factory used by the :mod:`repoze.bfg` router to create all request objects. - The ``Hooks`` narrative chapter now contains a section about changing the request factory.
Diffstat (limited to 'repoze/bfg/tests/test_scripting.py')
-rw-r--r--repoze/bfg/tests/test_scripting.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/repoze/bfg/tests/test_scripting.py b/repoze/bfg/tests/test_scripting.py
index 4d45a6456..2663c4a0f 100644
--- a/repoze/bfg/tests/test_scripting.py
+++ b/repoze/bfg/tests/test_scripting.py
@@ -28,12 +28,33 @@ class TestGetRoot(unittest.TestCase):
closer()
self.assertEqual(len(app.threadlocal_manager.popped), 1)
+ def test_it_requestfactory_overridden(self):
+ app = DummyApp()
+ request = Dummy()
+ class DummyFactory(object):
+ @classmethod
+ def blank(cls, path):
+ return request
+ registry = DummyRegistry(DummyFactory)
+ app.registry = registry
+ root, closer = self._callFUT(app)
+ self.assertEqual(len(app.threadlocal_manager.pushed), 1)
+ pushed = app.threadlocal_manager.pushed[0]
+ self.assertEqual(pushed['request'], request)
class Dummy:
pass
dummy_root = Dummy()
-dummy_registry = Dummy()
+
+class DummyRegistry(object):
+ def __init__(self, result=None):
+ self.result = result
+
+ def queryUtility(self, iface, default=None):
+ return self.result or default
+
+dummy_registry = DummyRegistry()
class DummyApp:
def __init__(self):