LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
[FIX] Replace unmaintained pytest-dotenv with direct dotenv loading (#1992)
Jaseem Jas12e06ddb796b
diff --git a/backend/conftest.py b/backend/conftest.pynew file mode 100644index 000000000..16452bb9e--- /dev/null+++ b/backend/conftest.py@@ -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)diff --git a/backend/pyproject.toml b/backend/pyproject.tomlindex 536b04332..7b520d3a8 100644--- a/backend/pyproject.toml+++ b/backend/pyproject.toml@@ -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@@ -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]diff --git a/backend/uv.lock b/backend/uv.lockindex 04d6894c1..bc5b7c6e7 100644--- a/backend/uv.lock+++ b/backend/uv.lock@@ -2983,19 +2983,6 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/3b/ab/b3226f0bd7cdcf710fbede2b3548584366da3b19b5021e74f5bde2a8fa3f/pytest-9.0.2-py3-none-any.whl", hash = "sha256:711ffd45bf766d5264d487b917733b453d917afd2b0ad65223959f59089f875b", size = 374801, upload-time = "2025-12-06T21:30:49.154Z" },]-[[package]]-name = "pytest-dotenv"-version = "0.5.2"-source = { registry = "https://pypi.org/simple" }-dependencies = [- { name = "pytest" },- { name = "python-dotenv" },-]-sdist = { url = "https://files.pythonhosted.org/packages/cd/b0/cafee9c627c1bae228eb07c9977f679b3a7cb111b488307ab9594ba9e4da/pytest-dotenv-0.5.2.tar.gz", hash = "sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732", size = 3782, upload-time = "2020-06-16T12:38:03.4Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/d0/da/9da67c67b3d0963160e3d2cbc7c38b6fae342670cc8e6d5936644b2cf944/pytest_dotenv-0.5.2-py3-none-any.whl", hash = "sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f", size = 3993, upload-time = "2020-06-16T12:38:01.139Z" },-]-[[package]]name = "python-crontab"version = "3.3.0"@@ -3745,7 +3732,6 @@ dev = []test = [{ name = "pytest" },- { name = "pytest-dotenv" },][package.metadata]@@ -3811,7 +3797,6 @@ dev = []test = [{ name = "pytest", specifier = ">=8.0.1" },- { name = "pytest-dotenv", specifier = "==0.5.2" },][[package]]diff --git a/prompt-service/pyproject.toml b/prompt-service/pyproject.tomlindex ae32c9520..5654af6e5 100644--- a/prompt-service/pyproject.toml+++ b/prompt-service/pyproject.toml@@ -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",diff --git a/prompt-service/uv.lock b/prompt-service/uv.lockindex b3a8cf1a6..30eea4ad0 100644--- a/prompt-service/uv.lock+++ b/prompt-service/uv.lock@@ -2200,19 +2200,6 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/ee/82/62e2d63639ecb0fbe8a7ee59ef0bc69a4669ec50f6d3459f74ad4e4189a2/pytest_asyncio-0.23.8-py3-none-any.whl", hash = "sha256:50265d892689a5faefb84df80819d1ecef566eb3549cf915dfb33569359d1ce2", size = 17663, upload-time = "2024-07-17T17:39:32.478Z" },]-[[package]]-name = "pytest-dotenv"-version = "0.5.2"-source = { registry = "https://pypi.org/simple" }-dependencies = [- { name = "pytest" },- { name = "python-dotenv" },-]-sdist = { url = "https://files.pythonhosted.org/packages/cd/b0/cafee9c627c1bae228eb07c9977f679b3a7cb111b488307ab9594ba9e4da/pytest-dotenv-0.5.2.tar.gz", hash = "sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732", size = 3782, upload-time = "2020-06-16T12:38:03.4Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/d0/da/9da67c67b3d0963160e3d2cbc7c38b6fae342670cc8e6d5936644b2cf944/pytest_dotenv-0.5.2-py3-none-any.whl", hash = "sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f", size = 3993, upload-time = "2020-06-16T12:38:01.139Z" },-]-[[package]]name = "pytest-md-report"version = "0.7.0"@@ -2780,7 +2767,6 @@ test = [{ name = "flask-wtf" },{ name = "pytest" },{ name = "pytest-asyncio" },- { name = "pytest-dotenv" },{ name = "pytest-md-report" },{ name = "pytest-mock" },{ name = "python-dotenv" },@@ -2815,7 +2801,6 @@ test = [{ name = "flask-wtf", specifier = "~=1.1" },{ name = "pytest", specifier = "~=8.0.1" },{ name = "pytest-asyncio", specifier = ">=0.23.0" },- { name = "pytest-dotenv", specifier = "==0.5.2" },{ name = "pytest-md-report", specifier = ">=0.6.2" },{ name = "pytest-mock", specifier = "~=3.14.0" },{ name = "python-dotenv", specifier = "==1.0.1" },