mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
webagg: tests: flush fakeredis for reentrancy
utils: add load_config() with option for main and override configs
This commit is contained in:
parent
45c8fcddbd
commit
80d9805a58
@ -68,6 +68,7 @@ class FakeRedisTests(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def teardown_class(cls):
|
def teardown_class(cls):
|
||||||
super(FakeRedisTests, cls).teardown_class()
|
super(FakeRedisTests, cls).teardown_class()
|
||||||
|
FakeStrictRedis().flushall()
|
||||||
cls.redismock.stop()
|
cls.redismock.stop()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import re
|
import re
|
||||||
import six
|
import six
|
||||||
import string
|
import string
|
||||||
|
import yaml
|
||||||
|
import os
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
@ -174,3 +176,25 @@ def chunk_encode_iter(orig_iter):
|
|||||||
yield b'0\r\n\r\n'
|
yield b'0\r\n\r\n'
|
||||||
|
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
def load_config(main_env_var, main_default_file='',
|
||||||
|
overlay_env_var='', overlay_file=''):
|
||||||
|
|
||||||
|
configfile = os.environ.get(main_env_var, main_default_file)
|
||||||
|
|
||||||
|
if configfile:
|
||||||
|
# Load config
|
||||||
|
with open(configfile, 'rb') as fh:
|
||||||
|
config = yaml.load(fh)
|
||||||
|
|
||||||
|
else:
|
||||||
|
config = {}
|
||||||
|
|
||||||
|
overlay_configfile = os.environ.get(overlay_env_var, overlay_file)
|
||||||
|
|
||||||
|
if overlay_configfile:
|
||||||
|
with open(overlay_configfile, 'rb') as fh:
|
||||||
|
config.update(yaml.load(fh))
|
||||||
|
|
||||||
|
return config
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user