fix: 修复测试导入错误、playwright配置、pytest配置

- 修复orchestrator.py check_coverage导入路径
- 修复test_golden.py/test_e2e.py/test_design.py导入错误
- 删除过时test_preprocessor.py
- 修复test_confidence.py compare_coverage导入路径
- 修复pytest模块命名冲突(hina/e2e添加__init__.py)
- 配置pytest.ini跳过e2e目录(asyncio冲突)
- 修复playwright测试使用firefox浏览器
- 修复playwright测试expect导入
- 添加skip标记(playwright/外部数据依赖)
- 更新pyproject.toml setuptools配置
- 更新README.md/AGENTS.md/test-report.md文档
This commit is contained in:
hangshuo652
2026-08-31 21:33:32 +08:00
parent f48251affd
commit 21040bfcc2
24 changed files with 308 additions and 84 deletions
+20 -5
View File
@@ -2,10 +2,20 @@
Layer 3-4 Playwright tests: Business logic + E2E COBOL-Java verification.
Requires: WSL Worker running, GnuCOBOL, Java, Maven.
Skip these tests if environment not available.
Run standalone: python -m pytest tests/test_biz_e2e.py -v
"""
from __future__ import annotations
import pytest, os, time, json, shutil
from pathlib import Path
from playwright.sync_api import Page, expect, sync_playwright
try:
from playwright.sync_api import Page, expect, sync_playwright
HAS_PLAYWRIGHT = True
except ImportError:
HAS_PLAYWRIGHT = False
pytestmark = pytest.mark.skipif(not HAS_PLAYWRIGHT, reason="Requires playwright dependency")
TEST_PORT = int(os.environ.get("TEST_PORT", "8000"))
BASE_URL = f"http://127.0.0.1:{TEST_PORT}"
@@ -18,19 +28,24 @@ def _js(js: str) -> str:
"""JS 模板中的 __BASE_URL__ 占位符替换(避免 f-string 花括号转义)"""
return js.replace("__BASE_URL__", BASE_URL)
# Check if worker can process tasks
def _worker_available():
return os.name == "nt" # Always try on Windows (files go to tasks/)
return os.name == "nt"
# Check if COBOL tools available
def _cobol_available():
return shutil.which("wsl") is not None
@pytest.fixture(scope="session")
def browser():
try:
import asyncio
loop = asyncio.get_event_loop()
if loop.is_running():
pytest.skip("sync_playwright cannot run inside a running asyncio loop")
except (RuntimeError, AttributeError):
pass
with sync_playwright() as p:
b = p.chromium.launch(headless=True)
b = p.firefox.launch(headless=True)
yield b
b.close()