How to use the everett.manager.ConfigManager.basic_config function in everett

To help you get started, we’ve selected a few everett examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github willkg / everett / tests / test_manager.py View on Github external
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"
github willkg / everett / tests / test_component.py View on Github external
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")