- 创建 scripts/ 目录作为核心代码根目录 - 移动 core/, readers/, utils/ 到 scripts/ 下 - 移动 config.py, lyxy_document_reader.py 到 scripts/ - 移动 encoding_detection.py 到 scripts/utils/ - 更新 pyproject.toml 中的入口点路径和 pytest 配置 - 更新所有内部导入语句为 scripts.* 模块 - 更新 README.md 目录结构说明 - 更新 openspec/config.yaml 添加目录结构说明 - 删除无用的 main.py 此变更使项目结构更清晰,便于区分核心代码与测试、文档等支撑文件。
33 lines
780 B
Python
33 lines
780 B
Python
"""测试文件检测工具函数。"""
|
|
|
|
from scripts.utils import is_url, is_html_file
|
|
|
|
|
|
class TestIsUrl:
|
|
"""测试 is_url 函数。"""
|
|
|
|
def test_http_url(self):
|
|
assert is_url("http://example.com") is True
|
|
|
|
def test_https_url(self):
|
|
assert is_url("https://example.com") is True
|
|
|
|
def test_not_url(self):
|
|
assert is_url("file.txt") is False
|
|
|
|
|
|
class TestIsHtmlFile:
|
|
"""测试 is_html_file 函数。"""
|
|
|
|
def test_html_extension(self):
|
|
assert is_html_file("file.html") is True
|
|
|
|
def test_htm_extension(self):
|
|
assert is_html_file("file.htm") is True
|
|
|
|
def test_uppercase_extension(self):
|
|
assert is_html_file("FILE.HTML") is True
|
|
|
|
def test_not_html(self):
|
|
assert is_html_file("file.txt") is False
|