fix: Host中间件审查修复(本地开发文档/顺序守护测试/ws断连分支/夹具清理)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
+4
-3
@@ -10,6 +10,7 @@ import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
||||
from sqlalchemy.pool import NullPool
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from app.engine.models import Base
|
||||
|
||||
@@ -152,7 +153,7 @@ def app_test_client(app_instance, base_url, cleanup_root):
|
||||
try:
|
||||
with TenantTestClient(
|
||||
app_instance, base_url=base_url,
|
||||
ws_default_host=base_url.removeprefix("http://")) as c:
|
||||
ws_default_host=urlsplit(base_url).netloc) as c:
|
||||
yield c
|
||||
finally:
|
||||
app_instance.state.registry = None
|
||||
@@ -171,8 +172,8 @@ def app_client(tmp_path):
|
||||
TestClient——同一 app 上两个 client 各跑一次 lifespan 会共享
|
||||
registry 而 engine 各绑一个循环,跨循环死锁。
|
||||
"""
|
||||
build_app(SEED_DIR, tmp_path)
|
||||
with app_test_client(app, f"http://{JIANCAI_HOST}", tmp_path) as c:
|
||||
a = build_app(SEED_DIR, tmp_path)
|
||||
with app_test_client(a, f"http://{JIANCAI_HOST}", tmp_path) as c:
|
||||
yield c
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user