use a contextmanager to set config values

so that when later tests run, the config has been restored to its
defaults and we don't end up failing later tests in confusing ways
This commit is contained in:
Leo Hemsted
2016-09-21 17:13:26 +01:00
parent 24903a19ef
commit 00b905bef0
2 changed files with 14 additions and 4 deletions

View File

@@ -1,3 +1,4 @@
from contextlib import contextmanager
import os
import boto3
@@ -83,3 +84,11 @@ def pytest_generate_tests(metafunc):
argnames, testdata = idparametrize.args
ids, argvalues = zip(*sorted(testdata.items()))
metafunc.parametrize(argnames, argvalues, ids=ids)
@contextmanager
def set_config(app, name, value):
old_val = app.config.get(name)
app.config[name] = value
yield
app.config[name] = old_val