mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-05 16:48:31 -04:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user