Implement environment singleton to be accessed throughout the code
Load and parse environment file from working dir Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
d1d8df7f72
commit
c69d8a3bd2
13 changed files with 151 additions and 64 deletions
|
|
@ -1,9 +1,14 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import functools
|
||||
import os
|
||||
|
||||
from . import mock
|
||||
from compose.config.config import ConfigDetails
|
||||
from compose.config.config import ConfigFile
|
||||
from compose.config.config import load
|
||||
from compose.config.environment import Environment
|
||||
|
||||
|
||||
def build_config(contents, **kwargs):
|
||||
|
|
@ -14,3 +19,11 @@ def build_config_details(contents, working_dir='working_dir', filename='filename
|
|||
return ConfigDetails(
|
||||
working_dir,
|
||||
[ConfigFile(filename, contents)])
|
||||
|
||||
|
||||
def clear_environment(f):
|
||||
@functools.wraps(f)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
Environment.reset()
|
||||
with mock.patch.dict(os.environ):
|
||||
f(self, *args, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue