little update
This commit is contained in:
23
tests/test_environment.py
Normal file
23
tests/test_environment.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
def test_dotenv_loads_missing_environment_value(tmp_path: Path, monkeypatch) -> None:
|
||||
env_file = tmp_path / ".env"
|
||||
env_file.write_text("CLOUD_PROJECT_ID=project-from-file\n")
|
||||
monkeypatch.delenv("CLOUD_PROJECT_ID", raising=False)
|
||||
|
||||
assert load_dotenv(env_file) is True
|
||||
assert os.environ["CLOUD_PROJECT_ID"] == "project-from-file"
|
||||
|
||||
|
||||
def test_dotenv_does_not_override_shell_environment(tmp_path: Path, monkeypatch) -> None:
|
||||
env_file = tmp_path / ".env"
|
||||
env_file.write_text("CLOUD_PROJECT_ID=project-from-file\n")
|
||||
monkeypatch.setenv("CLOUD_PROJECT_ID", "project-from-shell")
|
||||
|
||||
load_dotenv(env_file)
|
||||
|
||||
assert os.environ["CLOUD_PROJECT_ID"] == "project-from-shell"
|
||||
Reference in New Issue
Block a user