Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_does_not_parse_lists(self, datadir):
ini_filename = os.path.join(datadir, "config_test.ini")
cie = ConfigIniEnv([ini_filename])
assert cie.get("bar") == "test1,test2"
def test_multiple_files(self, datadir):
ini_filename = os.path.join(datadir, "config_test.ini")
ini_filename_original = os.path.join(datadir, "config_test_original.ini")
cie = ConfigIniEnv([ini_filename, ini_filename_original])
# Only the first found file is loaded, so foo_original does not exist
assert cie.get("foo_original") == NO_VALUE
cie = ConfigIniEnv([ini_filename_original])
# ... but it is there if only the original is loaded (safety check)
assert cie.get("foo_original") == "original"
def get_config():
return ConfigManager(
[ConfigIniEnv([os.environ.get("CIS_CONFIG_INI"), "~/.mozilla-cis.ini", "/etc/mozilla-cis.ini"]), ConfigOSEnv()]
)
def get_config():
return ConfigManager(
[ConfigIniEnv([os.environ.get("CIS_CONFIG_INI"), "~/.mozilla-cis.ini", "/etc/mozilla-cis.ini"]), ConfigOSEnv()]
)
def get_config():
return ConfigManager(
[
ConfigIniEnv([
os.environ.get('CIS_CONFIG_INI'),
'~/.mozilla-cis.ini',
'/etc/mozilla-cis.ini'
]),
ConfigOSEnv()
]
def get_config():
return ConfigManager(
[
ConfigIniEnv([
os.environ.get('THREATRESPONSE_INI'),
'~/.threatresponse.ini',
'/etc/threatresponse.ini'
]),
ConfigOSEnv()
]
import os
from everett.ext.inifile import ConfigIniEnv
from everett.manager import (
ConfigDictEnv,
ConfigManager,
ConfigOSEnv
)
config = ConfigManager([
# Pull from the OS environment first
ConfigOSEnv(),
# Fall back to the file specified by the FOO_INI OS environment
# variable if such file exists
ConfigIniEnv(os.environ.get('FOO_INI')),
# Fall back to this dict of defaults
ConfigDictEnv({
'FOO_VAR': 'bar'
})
])
assert config('foo_var') == 'bar'
def get_config():
return ConfigManager(
[ConfigIniEnv([os.environ.get("CIS_CONFIG_INI"), "~/.mozilla-cis.ini", "/etc/mozilla-cis.ini"]), ConfigOSEnv()]
)