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:
+20
-3
@@ -2,20 +2,37 @@
|
||||
Playwright E2E tests for COBOL-Java Migration Platform Web UI.
|
||||
Server must be running: python -m uvicorn web.api:app --host 127.0.0.1 --port $TEST_PORT
|
||||
(端口经 TEST_PORT 环境变量配置, 默认 8000)
|
||||
|
||||
Run standalone: python -m pytest tests/test_web_e2e.py -v
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import os
|
||||
|
||||
import pytest
|
||||
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
|
||||
|
||||
TEST_PORT = int(os.environ.get("TEST_PORT", "8000"))
|
||||
BASE_URL = f"http://127.0.0.1:{TEST_PORT}"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def browser():
|
||||
def browser(request):
|
||||
if not HAS_PLAYWRIGHT:
|
||||
pytest.skip("playwright not installed")
|
||||
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:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
browser = p.firefox.launch(headless=True)
|
||||
yield browser
|
||||
browser.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user