- Added comprehensive documentation for the unified screenshot and score recording process in the new markdown file. - Improved existing markdown files by adding spacing for better readability. - Cleaned up code by removing unnecessary blank lines across various scripts, enhancing overall code clarity. - Updated configuration settings to reflect recent changes and ensure consistency across the project. - Enhanced logging mechanisms to support better debugging and monitoring.
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""
|
|
版本信息模块测试
|
|
"""
|
|
|
|
import pytest # type: ignore[import-untyped]
|
|
from version import VERSION, RELEASE_DATE, print_version_banner
|
|
|
|
|
|
class TestVersion:
|
|
"""版本信息测试类"""
|
|
|
|
def test_version_exists(self):
|
|
"""测试版本号存在"""
|
|
assert VERSION is not None
|
|
assert isinstance(VERSION, str)
|
|
assert len(VERSION) > 0
|
|
|
|
def test_version_format(self):
|
|
"""测试版本号格式(应该是 x.y.z 格式)"""
|
|
parts = VERSION.split(".")
|
|
assert len(parts) >= 2, "版本号应该至少包含主版本号和次版本号"
|
|
for part in parts:
|
|
assert (
|
|
part.isdigit() or part.replace("-", "").isdigit()
|
|
), f"版本号部分 '{part}' 应该是数字"
|
|
|
|
def test_release_date_exists(self):
|
|
"""测试发布日期存在"""
|
|
assert RELEASE_DATE is not None
|
|
assert isinstance(RELEASE_DATE, str)
|
|
assert len(RELEASE_DATE) > 0
|
|
|
|
def test_release_date_format(self):
|
|
"""测试发布日期格式(应该是 YYYY-MM-DD 格式)"""
|
|
parts = RELEASE_DATE.split("-")
|
|
assert len(parts) == 3, "发布日期应该是 YYYY-MM-DD 格式"
|
|
assert len(parts[0]) == 4, "年份应该是4位数字"
|
|
assert len(parts[1]) == 2, "月份应该是2位数字"
|
|
assert len(parts[2]) == 2, "日期应该是2位数字"
|
|
|
|
def test_print_version_banner(self, capsys):
|
|
"""测试版本信息打印"""
|
|
print_version_banner()
|
|
captured = capsys.readouterr()
|
|
assert VERSION in captured.out
|
|
assert RELEASE_DATE in captured.out
|