[moz] fix(test): 补修 test_e2e_v31/test_four_phase 的 sys.path 污染
CI / lint (pull_request) Successful in 21s
CI / test (pull_request) Successful in 41s
CI / frontend (pull_request) Successful in 14s
CI / notify-on-failure (pull_request) Successful in 0s

PR #110 遗漏的两个文件,同样在模块级执行 sys.path.insert(DEPLOY_DIR)
导致 CI 中 src 模块从安装目录加载。统一加 allow_module_level skip guard。

- tests/e2e/test_e2e_v31.py
- tests/e2e/test_four_phase.py
This commit is contained in:
cfdaily
2026-06-22 06:30:46 +08:00
parent ac8444bb41
commit a402bb2a2d
2 changed files with 9 additions and 14 deletions
+4 -7
View File
@@ -1,12 +1,11 @@
import pytest import pytest
import os
if not os.environ.get("RUN_INTEGRATION"):
pytest.skip("E2E tests require RUN_INTEGRATION=1", allow_module_level=True)
pytestmark = pytest.mark.e2e pytestmark = pytest.mark.e2e
skip_no_integration = pytest.mark.skipif(
not __import__("os").environ.get("RUN_INTEGRATION"),
reason="Set RUN_INTEGRATION=1 to run E2E tests against real daemon",
)
"""v3.1 端到端测试 — 新增场景覆盖 """v3.1 端到端测试 — 新增场景覆盖
覆盖 v3.1 新增功能: 覆盖 v3.1 新增功能:
@@ -22,7 +21,6 @@ skip_no_integration = pytest.mark.skipif(
""" """
import json import json
import os
import sqlite3 import sqlite3
import sys import sys
import time import time
@@ -31,7 +29,6 @@ from datetime import datetime, timedelta
from pathlib import Path from pathlib import Path
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
import pytest
import requests as http_requests import requests as http_requests
# ── 路径设置 ── # ── 路径设置 ──
+5 -7
View File
@@ -1,10 +1,11 @@
import os import os
import sys
import pytest import pytest
pytestmark = [pytest.mark.e2e, pytest.mark.skipif( if not os.environ.get("RUN_INTEGRATION"):
not os.environ.get("RUN_INTEGRATION"), pytest.skip("E2E tests require RUN_INTEGRATION=1", allow_module_level=True)
reason="Set RUN_INTEGRATION=1 to run E2E tests",
)] pytestmark = [pytest.mark.e2e]
"""#01 四相循环 单元测试 """#01 四相循环 单元测试
@@ -23,13 +24,10 @@ pytestmark = [pytest.mark.e2e, pytest.mark.skipif(
import asyncio import asyncio
import json import json
import sys
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from unittest.mock import AsyncMock, MagicMock, patch from unittest.mock import AsyncMock, MagicMock, patch
import pytest
# ── 路径设置 ── # ── 路径设置 ──
DEPLOY_DIR = Path.home() / ".sanguo_projects" / "sanguo_moziplus_v2" DEPLOY_DIR = Path.home() / ".sanguo_projects" / "sanguo_moziplus_v2"
SRC_DIR = DEPLOY_DIR / "src" SRC_DIR = DEPLOY_DIR / "src"