-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include load with relative root path (#1049)
Co-authored-by: Bruno Rocha <rochacbruno@users.noreply.github.com>
- Loading branch information
1 parent
09a043f
commit fa8c748
Showing
4 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.PHONY: test | ||
|
||
test: | ||
pytest -sv app.py |
47 changes: 47 additions & 0 deletions
47
tests_functional/issues/1025_include-with-root-path/app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
""" | ||
[bug] dynaconf 3.2.2 broke dynaconf_include when combined with root_path | ||
https://github.com/dynaconf/dynaconf/issues/1025 | ||
""" | ||
from __future__ import annotations | ||
|
||
import os | ||
from textwrap import dedent | ||
|
||
from dynaconf import Dynaconf | ||
|
||
|
||
def create_file(name, data): | ||
with open(name, "w") as file: | ||
file.write(dedent(data)) | ||
|
||
return name | ||
|
||
|
||
def test_1025(tmp_path): | ||
os.chdir(tmp_path) | ||
basedir = tmp_path / "etc" | ||
basedir.mkdir() | ||
f1 = create_file( | ||
basedir / "f1.toml", | ||
""" | ||
dynaconf_include = [ | ||
"f2.toml", | ||
] | ||
name = "peter" | ||
""", | ||
) | ||
create_file( | ||
basedir / "f2.toml", | ||
""" | ||
age = 6 | ||
""", | ||
) | ||
|
||
settings = Dynaconf( | ||
settings_file=str(f1.absolute()), | ||
root_path=basedir.name, | ||
) | ||
assert settings.name | ||
assert settings.age |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters