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
elbehery95 authored and bbc2 committed Jul 3, 2020
1 parent d83c1b6 commit 6712bc8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

*No unreleased change at this time.*
### Fixed

- Privilege definition in file over the environment in variable expansion (#256 by
[@elbehery95]).

## [0.13.0] - 2020-04-16

Expand Down Expand Up @@ -197,6 +200,7 @@ project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
[@ulyssessouza]: https://github.com/ulyssessouza
[@venthur]: https://github.com/venthur
[@yannham]: https://github.com/yannham
[@elbehery95]: https://github.com/elbehery95

[Unreleased]: https://github.com/theskumar/python-dotenv/compare/v0.13.0...HEAD
[0.13.0]: https://github.com/theskumar/python-dotenv/compare/v0.12.0...v0.13.0
Expand Down
7 changes: 1 addition & 6 deletions src/dotenv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,8 @@ def resolve_nested_variables(values):
# type: (Dict[Text, Optional[Text]]) -> Dict[Text, Optional[Text]]
def _replacement(name, default):
# type: (Text, Optional[Text]) -> Text
"""
get appropriate value for a variable name.
first search in environ, if not found,
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
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ def test_dotenv_values_file(dotenv_file):
# Reused
({"b": "c"}, "a=${b}${b}", True, {"a": "cc"}),
# Re-defined and used in file
({"b": "c"}, "b=d\na=${b}", True, {"a": "d", "b": "d"}),
],
)
def test_dotenv_values_stream(env, string, interpolate, expected):
Expand Down

0 comments on commit 6712bc8

Please sign in to comment.