Michael Merickel
2011-07-12 54376af6ae324606a96bbc92629cfb2b0b375e12
Reverted get_root back to its behavior of expecting a router instance.
2 files modified
27 ■■■■ changed files
pyramid/scripting.py 5 ●●●● patch | view | raw | blame | history
pyramid/tests/test_scripting.py 22 ●●●● patch | view | raw | blame | history
pyramid/scripting.py
@@ -13,10 +13,7 @@
    :app:`Pyramid` application root factory. A request is constructed
    using :meth:`pyramid.scripting.make_request` and passed to the root
    factory if ``request`` is None."""
    if hasattr(app, 'registry'):
        registry = app.registry
    else:
        registry = global_registries.last
    registry = app.registry
    if request is None:
        request = make_request('/', registry)
    threadlocals = {'registry':registry, 'request':request}
pyramid/tests/test_scripting.py
@@ -35,30 +35,14 @@
        pushed = app.threadlocal_manager.pushed[0]
        self.assertEqual(pushed['request'].environ['path'], '/')
    def test_it_with_no_registry(self):
        from pyramid.config import global_registries
        app = DummyApp()
        # keep registry local so that global_registries is cleared after
        registry = DummyRegistry(DummyFactory)
        global_registries.add(registry)
        root, closer = self._callFUT(app)
        self.assertEqual(len(app.threadlocal_manager.pushed), 1)
        pushed = app.threadlocal_manager.pushed[0]
        self.assertEqual(pushed['request'].registry, registry)
class TestMakeRequest(unittest.TestCase):
    def _callFUT(self, path='/', registry=None):
        from pyramid.scripting import make_request
        return make_request(path, registry)
    def test_it(self):
    def test_it_with_registry(self):
        request = self._callFUT('/', dummy_registry)
        self.assertEqual(request.environ['path'], '/')
        self.assertEqual(request.registry, dummy_registry)
    def test_it_with_nondefault_path(self):
        request = self._callFUT('/users/login', dummy_registry)
        self.assertEqual(request.environ['path'], '/users/login')
        self.assertEqual(request.registry, dummy_registry)
    def test_it_with_no_registry(self):
@@ -66,8 +50,8 @@
        # keep registry local so that global_registries is cleared after
        registry = DummyRegistry(DummyFactory)
        global_registries.add(registry)
        request = self._callFUT()
        self.assertEqual(request.environ['path'], '/')
        request = self._callFUT('/hello')
        self.assertEqual(request.environ['path'], '/hello')
        self.assertEqual(request.registry, registry)
class Dummy: