1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 08:04:49 +01:00

webagg: tests: flush fakeredis for reentrancy

utils: add load_config() with option for main and override configs
This commit is contained in:
Ilya Kreymer 2016-05-19 17:01:09 -07:00
parent 45c8fcddbd
commit 80d9805a58
2 changed files with 25 additions and 0 deletions

View File

@ -68,6 +68,7 @@ class FakeRedisTests(object):
@classmethod
def teardown_class(cls):
super(FakeRedisTests, cls).teardown_class()
FakeStrictRedis().flushall()
cls.redismock.stop()

View File

@ -1,6 +1,8 @@
import re
import six
import string
import yaml
import os
from contextlib import closing
@ -174,3 +176,25 @@ def chunk_encode_iter(orig_iter):
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