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_basic_config(datadir):
os.environ["EVERETT_BASIC_CONFIG_TEST"] = "foo"
env_filename = os.path.join(datadir, ".env")
config = ConfigManager.basic_config(env_filename)
# This doesn't exist in either the environment or the env file
assert config("FOO", raise_error=False) is NO_VALUE
# This exists in the environment
assert config("EVERETT_BASIC_CONFIG_TEST") == "foo"
# This exists in the env file
assert config("LOGLEVEL") == "walter"
def test_nested_options():
"""Verify nested BoundOptions works."""
config = ConfigManager.from_dict({})
class Foo(RequiredConfigMixin):
required_config = ConfigOptions()
required_config.add_option("option1", default="opt1default", parser=str)
class Bar(RequiredConfigMixin):
required_config = ConfigOptions()
required_config.add_option("option2", default="opt2default", parser=str)
config = ConfigManager.basic_config()
config = config.with_options(Foo)
config = config.with_options(Bar)
assert config("option2") == "opt2default"
with pytest.raises(ConfigurationError):
config("option1")