跳转至

Python 测试

此文件使用 Python 特定内容扩展 common/testing.md。

测试框架

使用 pytest 作为测试框架。

覆盖率

pytest --cov=src --cov-report=term-missing

测试结构

使用 pytest.mark 进行测试分类:

import pytest

@pytest.mark.unit
def test_calculate_total():
    ...

@pytest.mark.integration
def test_database_connection():
    ...

参考

技能:在 python-testing 中查看详细的 pytest 模式和 fixture。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 ev/ECC