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
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
def test_raise_error_when_no_default_set(): with pytest.raises(ConfigError): get_from_env(**env(str_key))
def test_get_default(): assert get_from_env(**env(str_key, default=str_value)) == str_value
def test_get_bool(): os.environ.setdefault(bool_key, str(bool_value)) assert get_from_env(**env(bool_key, cast=bool)) is True
def test_get_str(): os.environ.setdefault(str_key, str_value) assert get_from_env(**env(str_key)) == str_value