From a402bb2a2db109fc8769cbfdbe57061b97fded38 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Mon, 22 Jun 2026 06:30:46 +0800 Subject: [PATCH] =?UTF-8?q?[moz]=20fix(test):=20=E8=A1=A5=E4=BF=AE=20test?= =?UTF-8?q?=5Fe2e=5Fv31/test=5Ffour=5Fphase=20=E7=9A=84=20sys.path=20?= =?UTF-8?q?=E6=B1=A1=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/e2e/test_e2e_v31.py | 11 ++++------- tests/e2e/test_four_phase.py | 12 +++++------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tests/e2e/test_e2e_v31.py b/tests/e2e/test_e2e_v31.py index c0cac5b..5b6acfd 100644 --- a/tests/e2e/test_e2e_v31.py +++ b/tests/e2e/test_e2e_v31.py @@ -1,12 +1,11 @@ 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 -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 新增功能: @@ -22,7 +21,6 @@ skip_no_integration = pytest.mark.skipif( """ import json -import os import sqlite3 import sys import time @@ -31,7 +29,6 @@ from datetime import datetime, timedelta from pathlib import Path from typing import Any, Dict, Optional -import pytest import requests as http_requests # ── 路径设置 ── diff --git a/tests/e2e/test_four_phase.py b/tests/e2e/test_four_phase.py index 388b61e..b837338 100644 --- a/tests/e2e/test_four_phase.py +++ b/tests/e2e/test_four_phase.py @@ -1,10 +1,11 @@ import os +import sys import pytest -pytestmark = [pytest.mark.e2e, pytest.mark.skipif( - not os.environ.get("RUN_INTEGRATION"), - reason="Set RUN_INTEGRATION=1 to run E2E tests", -)] +if not os.environ.get("RUN_INTEGRATION"): + pytest.skip("E2E tests require RUN_INTEGRATION=1", allow_module_level=True) + +pytestmark = [pytest.mark.e2e] """#01 四相循环 单元测试 @@ -23,13 +24,10 @@ pytestmark = [pytest.mark.e2e, pytest.mark.skipif( import asyncio import json -import sys from pathlib import Path from typing import Any, Dict, List, Optional from unittest.mock import AsyncMock, MagicMock, patch -import pytest - # ── 路径设置 ── DEPLOY_DIR = Path.home() / ".sanguo_projects" / "sanguo_moziplus_v2" SRC_DIR = DEPLOY_DIR / "src"