From de79bc7acb291a19d7515700f910004b7ea0c868 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 23 Aug 2011 03:16:26 -0400 Subject: fix integration test --- pyramid/config/routes.py | 16 +++++++++++----- pyramid/tests/test_integration.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pyramid/config/routes.py b/pyramid/config/routes.py index f92d4bd75..0360bad9d 100644 --- a/pyramid/config/routes.py +++ b/pyramid/config/routes.py @@ -356,7 +356,7 @@ class RoutesConfiguratorMixin(object): mapper = self.get_routes_mapper() - def register_route(): + def register_route_request_iface(): request_iface = self.registry.queryUtility(IRouteRequest, name=name) if request_iface is None: if use_global_views: @@ -367,14 +367,20 @@ class RoutesConfiguratorMixin(object): self.registry.registerUtility( request_iface, IRouteRequest, name=name) + def register_connect(): return mapper.connect(name, pattern, factory, predicates=predicates, pregenerator=pregenerator, static=static) - # route actions must run before view registration actions; all - # IRouteRequest interfaces must be registered before we begin to - # process view registrations - self.action(('route', name), register_route, order=PHASE2_CONFIG) + # We have to connect routes in the order they were provided; + # we can't use a phase to do that, because when the actions are + # sorted, actions in the same phase lose relative ordering + self.action(None, register_connect) + + # But IRouteRequest interfaces must be registered before we begin to + # process view registrations (in phase 3) + self.action(('route', name), register_route_request_iface, + order=PHASE2_CONFIG) # deprecated adding views from add_route; must come after # route registration for purposes of autocommit ordering diff --git a/pyramid/tests/test_integration.py b/pyramid/tests/test_integration.py index 1ebf83062..d9e5c591f 100644 --- a/pyramid/tests/test_integration.py +++ b/pyramid/tests/test_integration.py @@ -192,6 +192,17 @@ class TestCCBug(IntegrationBase): # "unordered" as reported in IRC by author of # http://labs.creativecommons.org/2010/01/13/cc-engine-and-web-non-frameworks/ package = 'pyramid.tests.ccbugapp' + + def setUp(self): + from pyramid.config import Configurator + config = Configurator(root_factory=self.root_factory, + package=self.package) + config.include(self.package) + app = config.make_wsgi_app() + from webtest import TestApp + self.testapp = TestApp(app) + self.config = config + def test_rdf(self): res = self.testapp.get('/licenses/1/v1/rdf', status=200) self.assertEqual(res.body, 'rdf') -- cgit v1.2.3