-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
353b1c1
commit 4dadf0e
Showing
5 changed files
with
62 additions
and
2 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
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,44 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
from dynaconf import Dynaconf | ||
|
||
HERE = Path(__file__).parent | ||
|
||
os.environ["DYNACONF_NAME"] = "stay fresh" | ||
settings = Dynaconf( | ||
fresh_vars=["name", "AGE"], settings_files=["settings.toml"] | ||
) | ||
|
||
|
||
def do_the_sets(age: int = 10): | ||
with open(HERE / "settings.toml", "w") as sf: | ||
sf.write(f"age = {age}") | ||
|
||
settings.name = "not so fresh" # NO EFFECT | ||
settings.NAME = "not so fresh" | ||
settings.NaMe = "not so fresh" | ||
settings.set("name", "not so fresh") | ||
settings["name"] = "not so fresh" | ||
|
||
print(settings.name) | ||
print(settings.age) | ||
|
||
|
||
do_the_sets() | ||
assert settings["NAME"] == "stay fresh" | ||
assert settings["AGE"] == 10 | ||
do_the_sets(20) | ||
assert settings.name == "stay fresh" | ||
assert settings["AGE"] == 20 | ||
do_the_sets(30) | ||
assert settings.NAME == "stay fresh" | ||
assert settings["AGE"] == 30 | ||
do_the_sets(40) | ||
assert settings["NAME"] == "stay fresh" | ||
assert settings["AGE"] == 40 | ||
do_the_sets(50) | ||
assert settings("NAME") == "stay fresh" | ||
assert settings["AGE"] == 50 |
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 @@ | ||
age = 50 |