示例#1
0
def test_parse_config_with_env_file(app):
    config = {str_name: env(str_key)}

    os.environ.setdefault(str_key, str_value)

    parse_config(app, config)

    assert app.settings[str_name] == str_value
示例#2
0
def test_parse_config(app, pathlib_tmpdir):
    env_file = pathlib_tmpdir / '.env'

    config = {str_name: env(str_key)}

    with open(env_file, 'w') as f:
        f.write('{}={}'.format(str_key, str_value))

    parse_config(app, config, env_file)

    assert app.settings[str_name] == str_value
示例#3
0
def test_raise_error_when_no_default_set():
    with pytest.raises(ConfigError):
        get_from_env(**env(str_key))
示例#4
0
def test_get_default():
    assert get_from_env(**env(str_key, default=str_value)) == str_value
示例#5
0
def test_get_bool():
    os.environ.setdefault(bool_key, str(bool_value))
    assert get_from_env(**env(bool_key, cast=bool)) is True
示例#6
0
def test_get_str():
    os.environ.setdefault(str_key, str_value)
    assert get_from_env(**env(str_key)) == str_value