diff options
Diffstat (limited to 'mediagoblin/tests/tools.py')
-rw-r--r-- | mediagoblin/tests/tools.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/mediagoblin/tests/tools.py b/mediagoblin/tests/tools.py index 70b74b89..342b54b7 100644 --- a/mediagoblin/tests/tools.py +++ b/mediagoblin/tests/tools.py @@ -18,10 +18,11 @@ import pkg_resources import os, shutil -from paste.deploy import appconfig +from paste.deploy import appconfig, loadapp from webtest import TestApp -from mediagoblin import app +from mediagoblin import util +from mediagoblin.decorators import _make_safe from mediagoblin.db.open import setup_connection_and_db_from_config @@ -88,7 +89,21 @@ def get_test_app(dump_old_app=True): # TODO: Drop and recreate indexes # setup app and return - test_app = app.paste_app_factory( - config.global_conf, **config.local_conf) + test_app = loadapp( + 'config:' + TEST_APP_CONFIG) return TestApp(test_app) + + +def setup_fresh_app(func): + """ + Decorator to setup a fresh test application for this function. + + Cleans out test buckets and passes in a new, fresh test_app. + """ + def wrapper(*args, **kwargs): + test_app = get_test_app() + util.clear_test_buckets() + return func(test_app, *args, **kwargs) + + return _make_safe(wrapper, func) |