Pass arbitrary keyword args to load_test_app

Applications can be written with arbitrary keyword arguments
in `setup_app`. The test app builder should support this by
allowing arbitrary keyword args to be passed to `load_test_app`,
and pass those along to `load_app`.

Change-Id: Icb3d5c39d0bf147c1e58732be3199a30a7539f6f
This commit is contained in:
Jim Rollenhagen
2014-03-18 11:19:17 -07:00
parent c047087b72
commit 2227b15247
2 changed files with 4 additions and 4 deletions

View File

@@ -142,7 +142,7 @@ def render(template, namespace):
return state.app.render(template, namespace)
def load_app(config):
def load_app(config, **kwargs):
'''
Used to load a ``Pecan`` application and its environment based on passed
configuration.
@@ -158,7 +158,7 @@ def load_app(config):
for package_name in getattr(_runtime_conf.app, 'modules', []):
module = __import__(package_name, fromlist=['app'])
if hasattr(module, 'app') and hasattr(module.app, 'setup_app'):
app = module.app.setup_app(_runtime_conf)
app = module.app.setup_app(_runtime_conf, **kwargs)
app.config = _runtime_conf
return app
raise RuntimeError(

View File

@@ -2,7 +2,7 @@ from pecan import load_app
from webtest import TestApp
def load_test_app(config=None):
def load_test_app(config=None, **kwargs):
"""
Used for functional tests where you need to test your
literal application and its integration with the framework.
@@ -32,4 +32,4 @@ def load_test_app(config=None):
resp = app.get('/path/to/some/resource').status_int
assert resp.status_int == 200
"""
return TestApp(load_app(config))
return TestApp(load_app(config, **kwargs))