We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 82a964a commit 2a4af9aCopy full SHA for 2a4af9a
app/tests/conftest.py
@@ -0,0 +1,9 @@
1
+from pathlib import Path
2
+import pytest
3
+from dotenv import load_dotenv
4
+
5
+# to load env variables to an interactive session for tests to work run the export $(grep -v '^#' .env | xargs) command
6
7
+@pytest.fixture(scope="session", autouse=True)
8
+def load_env():
9
+ load_dotenv(dotenv_path=Path("../../../config/.env"))
app/tests/test_load_env.py
@@ -0,0 +1,6 @@
+import os
+def test_env_loaded():
+ ret = os.getenv("API_KEY", "")
+ assert ret is not None, "API_KEY not loaded!"
+ print(ret)
0 commit comments