Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions backend/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""Top-level pytest conftest for the backend service.

Loads environment variables from ``test.env`` before pytest collects any
test modules. This replaces the ``pytest-dotenv`` plugin, which has been
unreleased since Feb 2020 and is a recurring break risk across pytest
majors.

Behavior matches the previous ``env_files = "test.env"`` setting under
``[tool.pytest.ini_options]``: variables already in the process
environment are preserved (``override=False``); a missing file is
silently tolerated.

Note: backend tests do not run under tox in CI today (no ``backend``
testenv); this file only takes effect in local/IDE runs.
"""

from pathlib import Path

from dotenv import load_dotenv

# `-s` is set in pyproject so prints surface — log when test.env is absent
# to make a mis-located file debuggable instead of silently empty.
if not load_dotenv(Path(__file__).parent / "test.env", override=False):
print("[conftest] backend/test.env not found; using ambient environment", flush=True)
5 changes: 3 additions & 2 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ dev = [
"responses>=0.25.7",
"psutil>=7.0.0",
]
test = ["pytest>=8.0.1", "pytest-dotenv==0.5.2"]
test = ["pytest>=8.0.1"]
deploy = [
"gunicorn~=23.0", # For serving the application
# Keep versions empty and let uv decide version
Expand All @@ -98,7 +98,8 @@ constraint-dependencies = [
]

[tool.pytest.ini_options]
env_files = "test.env" # Load env from particular env file
# Note: test.env is loaded by backend/conftest.py via python-dotenv directly
# (replaces the unmaintained pytest-dotenv plugin).
addopts = "-s"

[tool.poe]
Expand Down
15 changes: 0 additions & 15 deletions backend/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion prompt-service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ unstract-sdk1 = { path = "../unstract/sdk1", editable = true }
test = [
"pytest~=8.0.1",
"pytest-asyncio>=0.23.0",
"pytest-dotenv==0.5.2",
"pytest-mock~=3.14.0",
"pytest-md-report>=0.6.2",
"python-dotenv==1.0.1",
Expand Down
15 changes: 0 additions & 15 deletions prompt-service/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading