Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rebind current env when forced for Pytest Fix #728
- Loading branch information
1 parent
cacfa29
commit 498c03a
Showing
5 changed files
with
38 additions
and
0 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 tests.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,9 @@ | ||
from __future__ import annotations | ||
|
||
from dynaconf import Dynaconf | ||
|
||
settings = Dynaconf( | ||
envvar_prefix="ISSUE728", | ||
settings_files=["settings.toml", ".secrets.toml"], | ||
environments=True, | ||
) |
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,8 @@ | ||
[default] | ||
name = "default name" | ||
|
||
[development] | ||
name = "development name" | ||
|
||
[testing] | ||
name = "testing name" |
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,16 @@ | ||
from __future__ import annotations | ||
|
||
import pytest | ||
from config import settings | ||
|
||
|
||
@pytest.fixture(scope="session", autouse=True) | ||
def set_test_settings(): | ||
settings.configure(FORCE_ENV_FOR_DYNACONF="testing") | ||
assert settings.current_env == "testing" | ||
|
||
|
||
def test_running_on_testing_environment(): | ||
assert settings.current_env == "testing" | ||
assert settings.ENV_FOR_DYNACONF == "testing" | ||
assert settings.NAME == "testing name" |