I've a Pyramid app that's composed of multiple python distributions
(packages). I'm writing integration tests for the code that calls
Configurator() and then uses the resulting config to do
config.include() on the various components.
The application uses URL dispatch. Mostly, the config.included()ed
components setup routes to their views. But routes can also be
overridden by settings, sometimes settings acted upon by the included
components and sometimes settings acted upon by my main Pyramid app.
Route prefixes are added and removed at a couple of points in the
I want a functional test to check that the configuration produced by
my code establishes the expected routes -- that the route names exist
and that when request.route_url() (etc.) are called the expected URLs
result. I can't find a direct way to do this.
I _could_ use WebTest to call my wsgi app, passing it various paths
and poking about inside the result body to try to figure out that the
right view was called. But this seems clunky and does not directly
tell me that I've got the right route names in existence and that they
produce the right paths.
I can't seem to use pyramid.testing.SetUp() to generate a request so
that I can call request.route_path(). SetUp() returns it's own
configuration, but I want to test the configuration produced by my
The code I want to test is, roughly:
rp = settings.get('route_prefix')
with Configurator(settings=settings, route_prefix=rp) as config:
for component in components_to_config():
return config # to main(), which returns config.make_wsgi() to pyramid
Any help would be appreciated. Thanks.
There is a related issue. I don't use route patterns that contain
replacement markers. The route paths are "fixed". I make a many of
the route paths available to my templates, for navbar generation ,etc.
Presently I'm calling request.route_path(), at runtime when generating
a response, with route names determined based on whatever
config.include()ed components happen to be installed. The results go
into a data structure made available to my templates. But this data
structure is the same for every request. It would be nice to produce
the data during configuration and re-use it when requests arrive.
I seem to have the same problem discovering route paths for my templates
during configuration that I have when trying to write an integration test
that discovers the route paths configured go with my route names. There's
no way to give a configuration a route name and get a route path.
(Presumably, such a thing would have to be done after calling
I can file an issue at github if that would help resolve any of these
questions and keep them from getting lost.
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein