From e0e8a2fc7cf5406d0f887cc7bba2acbb18d0fef4 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 23 Jan 2013 18:31:19 -0500 Subject: [PATCH] testing will load an app with no config arg passed in --- pecan/testing.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pecan/testing.py b/pecan/testing.py index b690ff2..ee2896e 100644 --- a/pecan/testing.py +++ b/pecan/testing.py @@ -2,13 +2,15 @@ from pecan import load_app from webtest import TestApp -def load_test_app(config): +def load_test_app(config=None): """ Used for functional tests where you need to test your literal application and its integration with the framework. - :param config: Can be a dictionary containing configuration, or a string - which represents a (relative) configuration filename. + :param config: Can be a dictionary containing configuration, a string which + represents a (relative) configuration filename or ``None`` + which will fallback to get the ``PECAN_CONFIG`` env + variable. returns a pecan.Pecan WSGI application wrapped in a webtest.TestApp instance. @@ -21,5 +23,13 @@ def load_test_app(config): resp = app.post('/path/to/some/resource', params={'param': 'value'}) assert resp.status_int == 302 + + Alternatively you could call ``load_test_app`` with no parameters if the + environment variable is set :: + + app = load_test_app() + + resp = app.get('/path/to/some/resource').status_int + assert resp.status_int == 200 """ return TestApp(load_app(config))