Skip to content

Commit

Permalink
fix interpolation order
Browse files Browse the repository at this point in the history
add interpolation order test
  • Loading branch information
root authored and root committed Jun 27, 2020
1 parent d83c1b6 commit b29a227
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dotenv/main.py
Expand Up @@ -220,7 +220,7 @@ def _replacement(name, default):
then look into the dotenv variables
"""
default = default if default is not None else ""
ret = os.getenv(name, new_values.get(name, default))
ret = new_values.get(name, os.getenv(name, default))
return ret # type: ignore

def _re_sub_callback(match):
Expand Down
3 changes: 3 additions & 0 deletions tests/test_main.py
Expand Up @@ -334,6 +334,9 @@ def test_dotenv_values_file(dotenv_file):
# Reused
({"b": "c"}, "a=${b}${b}", True, {"a": "cc"}),
# interpolate with re-defined var
({"b": "b_os_env"}, "b='b_dot_env'\na=a/${b}", True, {"a": "a/b_dot_env", "b": "b_dot_env"})
],
)
def test_dotenv_values_stream(env, string, interpolate, expected):
Expand Down

0 comments on commit b29a227

Please sign in to comment.