Files
lyxy-document/tests/test_readers/test_html_downloader.py
lanyuanxiaoyao c90e1c98be test: 补充缺失的核心模块测试,统一CLI测试行为
新增测试文件:
- tests/test_core/test_parser.py - 测试 parse_input/process_content/output_result
- tests/test_core/test_markdown_extra.py - 测试 extract_title_content/search_markdown
- tests/test_utils/test_encoding_detection.py - 测试编码检测模块
- tests/test_readers/test_html_downloader.py - 测试HTML下载器

修改:
- tests/conftest.py - 移除pytest.skip(),所有CLI测试在缺少依赖时直接失败(与HTML测试行为一致)
2026-03-12 01:18:13 +08:00

44 lines
1.4 KiB
Python

"""测试 HTML 下载器模块。"""
import pytest
from unittest.mock import patch, MagicMock
from readers.html.downloader import download_html
from readers.html.downloader import pyppeteer, selenium, httpx, urllib
class TestDownloadHtml:
"""测试 download_html 统一入口函数。"""
def test_download_html_module_importable(self):
"""测试 download_html 函数可以正常导入和调用。"""
# 只要不抛异常就可以
assert callable(download_html)
def test_downloaders_available(self):
"""测试各下载器模块可用。"""
assert callable(pyppeteer.download)
assert callable(selenium.download)
assert callable(httpx.download)
assert callable(urllib.download)
class TestIndividualDownloaders:
"""测试单个下载器模块。"""
def test_pyppeteer_download_callable(self):
"""测试 pyppeteer.download 可以调用。"""
assert callable(pyppeteer.download)
def test_selenium_download_callable(self):
"""测试 selenium.download 可以调用。"""
assert callable(selenium.download)
def test_httpx_download_callable(self):
"""测试 httpx.download 可以调用。"""
assert callable(httpx.download)
def test_urllib_download_callable(self):
"""测试 urllib.download 可以调用(标准库)。"""
assert callable(urllib.download)