Turning setup_fresh_app into SetupFreshApp, a decorator with options!
This way people can pass in particular paste/mediagoblin configs that they want to use.
This commit is contained in:
parent
6588acc183
commit
245d4f119f
@ -171,19 +171,29 @@ def get_app(paste_config=None, mgoblin_config=None, dump_old_app=True):
|
|||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
def setup_fresh_app(func):
|
class SetupFreshApp(object):
|
||||||
"""
|
"""
|
||||||
Decorator to setup a fresh test application for this function.
|
Decorator to setup a fresh test application for this function.
|
||||||
|
|
||||||
Cleans out test buckets and passes in a new, fresh test_app.
|
Cleans out test buckets and passes in a new, fresh test_app.
|
||||||
"""
|
"""
|
||||||
@wraps(func)
|
def __init__(self, paste_config, mgoblin_config, dump_old_app=True):
|
||||||
def wrapper(*args, **kwargs):
|
self.paste_config = paste_config
|
||||||
test_app = get_app()
|
self.mgoblin_config = mgoblin_config
|
||||||
testing.clear_test_buckets()
|
|
||||||
return func(test_app, *args, **kwargs)
|
|
||||||
|
|
||||||
return wrapper
|
def __call__(self, func):
|
||||||
|
@wraps(func)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
test_app = get_app(
|
||||||
|
paste_config=self.paste_config,
|
||||||
|
mgoblin_config=self.mgoblin_config,
|
||||||
|
dump_old_app=self.dump_old_app)
|
||||||
|
testing.clear_test_buckets()
|
||||||
|
return func(test_app, *args, **kwargs)
|
||||||
|
|
||||||
|
return wrapper
|
||||||
|
|
||||||
|
setup_fresh_app = SetupFreshApp(TEST_SERVER_CONFIG, TEST_APP_CONFIG)
|
||||||
|
|
||||||
|
|
||||||
def install_fixtures_simple(db, fixtures):
|
def install_fixtures_simple(db, fixtures):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user