refactor: 简化代码,消除重复逻辑
- 删除 tests/test_readers/conftest.py 中重复的 temp_html fixture - 为 generate_uv_command/generate_python_command 添加 include_pyarmor 参数 - 新增 generate_uv_args 函数用于生成 subprocess 可用的参数列表 - lyxy_document_reader.py 复用 generate_uv_args 函数
This commit is contained in:
@@ -4,32 +4,6 @@ import pytest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def temp_html(tmp_path):
|
||||
"""创建临时 HTML 文件的 fixture 工厂。
|
||||
|
||||
Args:
|
||||
content: HTML 内容字符串
|
||||
encoding: 文件编码,默认 'utf-8'
|
||||
|
||||
Returns:
|
||||
str: 临时文件路径
|
||||
"""
|
||||
def _create_html(content="<html><body><p>Test</p></body></html>", encoding='utf-8'):
|
||||
file_path = tmp_path / "test.html"
|
||||
|
||||
# 如果内容不包含完整的 HTML 结构,添加基本结构
|
||||
if not content.strip().startswith('<html'):
|
||||
content = f"<html><head><meta charset='{encoding}'></head><body>{content}</body></html>"
|
||||
|
||||
with open(file_path, 'w', encoding=encoding) as f:
|
||||
f.write(content)
|
||||
|
||||
return str(file_path)
|
||||
|
||||
return _create_html
|
||||
|
||||
|
||||
# 静态测试文件目录
|
||||
FIXTURES_DIR = Path(__file__).parent / "fixtures"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user