feat: Add coverage report generation and enhance testing framework
- Introduced a new `.coverage` file for tracking test coverage metrics. - Added `pytest.ini` configuration for streamlined testing setup, including coverage reporting and logging options. - Created `requirements-test.txt` to manage testing dependencies, ensuring a consistent testing environment. - Implemented a `run_tests.py` script to facilitate running tests with various options, including unit and integration tests. - Established a structured testing directory with unit and integration tests, enhancing code reliability and maintainability. - Updated documentation to reflect new testing procedures and configurations.
This commit is contained in:
1 parent
ce4a332dc0
commit
539e580147
44 files changed
+11824
-9501
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"""
|
||||
版本信息模块测试
|
||||
"""
|
||||
|
||||
import pytest
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user