fix(webui): package-qualify webui_testclient import across test suite (Closes #682)

This commit is contained in:
2026-07-24 18:18:10 -04:00
parent 5deb66c7f6
commit c74b8da400
19 changed files with 44 additions and 38 deletions
+11 -5
View File
@@ -9,7 +9,6 @@ import warnings
from pathlib import Path from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
sys.path.insert(0, str(Path(__file__).resolve().parent))
class TestHttpx2Installed(unittest.TestCase): class TestHttpx2Installed(unittest.TestCase):
@@ -21,9 +20,14 @@ class TestHttpx2Installed(unittest.TestCase):
class TestNoStarletteTestClientDeprecation(unittest.TestCase): class TestNoStarletteTestClientDeprecation(unittest.TestCase):
def test_starlette_testclient_import_does_not_warn(self) -> None: def test_starlette_testclient_import_does_not_warn(self) -> None:
# Force a fresh import path so a previous httpx-fallback warning cannot # Force a fresh import path so a previous httpx-fallback warning cannot
# hide a regression after httpx2 is present. # hide a regression after httpx2 is present. Restore sys.modules afterwards.
for name in list(sys.modules): saved = {
if name == "starlette.testclient" or name.startswith("starlette.testclient."): name: sys.modules[name]
for name in list(sys.modules)
if name == "starlette.testclient" or name.startswith("starlette.testclient.")
}
try:
for name in list(saved):
del sys.modules[name] del sys.modules[name]
with warnings.catch_warnings(record=True) as caught: with warnings.catch_warnings(record=True) as caught:
@@ -42,11 +46,13 @@ class TestNoStarletteTestClientDeprecation(unittest.TestCase):
f"expected no Starlette httpx deprecation warning; got: " f"expected no Starlette httpx deprecation warning; got: "
f"{[str(w.message) for w in dep]}", f"{[str(w.message) for w in dep]}",
) )
finally:
sys.modules.update(saved)
def test_canonical_webui_testclient_import(self) -> None: def test_canonical_webui_testclient_import(self) -> None:
with warnings.catch_warnings(record=True) as caught: with warnings.catch_warnings(record=True) as caught:
warnings.simplefilter("always") warnings.simplefilter("always")
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
client = TestClient(create_app()) client = TestClient(create_app())
+1 -1
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
import os import os
import tempfile import tempfile
import unittest import unittest
from webui_testclient import TestClient from tests.webui_testclient import TestClient
import control_plane_db import control_plane_db
from webui.analytics_loader import ( from webui.analytics_loader import (
+1 -1
View File
@@ -5,7 +5,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.audit_validator import audit_report, infer_task_kind from webui.audit_validator import audit_report, infer_task_kind
+1 -1
View File
@@ -23,7 +23,7 @@ import sys
import tempfile import tempfile
import unittest import unittest
from webui_testclient import TestClient from tests.webui_testclient import TestClient
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
+1 -1
View File
@@ -7,7 +7,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.deployment_boundary import ( from webui.deployment_boundary import (
+1 -1
View File
@@ -6,7 +6,7 @@ from unittest.mock import patch
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from task_capability_map import TASK_CAPABILITY_MAP from task_capability_map import TASK_CAPABILITY_MAP
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -15,7 +15,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
import control_plane_db import control_plane_db
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -5,7 +5,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.lease_loader import ( from webui.lease_loader import (
+1 -1
View File
@@ -9,7 +9,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from starlette.routing import Route from starlette.routing import Route
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -7,7 +7,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.project_registry import ( from webui.project_registry import (
+1 -1
View File
@@ -6,7 +6,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.prompt_library import find_prompt, library_to_dict, load_prompt_library, prompt_to_dict from webui.prompt_library import find_prompt, library_to_dict, load_prompt_library, prompt_to_dict
+1 -1
View File
@@ -7,7 +7,7 @@ from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.queue_loader import ( from webui.queue_loader import (
+1 -1
View File
@@ -6,7 +6,7 @@ from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.runtime_health import _role_kind, load_runtime_snapshot, snapshot_to_dict from webui.runtime_health import _role_kind, load_runtime_snapshot, snapshot_to_dict
+1 -1
View File
@@ -6,7 +6,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from starlette.routing import Route from starlette.routing import Route
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui import layout from webui import layout
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -5,7 +5,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -16,7 +16,7 @@ from unittest import mock
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
import control_plane_db import control_plane_db
from webui.app import create_app from webui.app import create_app
+1 -1
View File
@@ -11,7 +11,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.deployment_boundary import scan_text_for_client_secrets from webui.deployment_boundary import scan_text_for_client_secrets
+1 -1
View File
@@ -13,7 +13,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
import control_plane_db import control_plane_db
from canonical_thread_handoff import ( from canonical_thread_handoff import (
+1 -1
View File
@@ -7,7 +7,7 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from webui_testclient import TestClient from tests.webui_testclient import TestClient
from webui.app import create_app from webui.app import create_app
from webui.worktree_scanner import ( from webui.worktree_scanner import (