claude-code/claude-zh/rules/python/testing.md

39 lines
647 B
Markdown
Raw Normal View History

2026-02-27 13:45:37 +00:00
---
paths:
- "**/*.py"
- "**/*.pyi"
---
# Python 測試 (Testing)
> 本檔案擴展了 [common/testing.md](../common/testing.md),包含 Python 特定內容。
## 框架 (Framework)
使用 **pytest** 作為測試框架。
## 覆蓋率 (Coverage)
```bash
pytest --cov=src --cov-report=term-missing
```
## 測試組織 (Test Organization)
使用 `pytest.mark` 進行測試分類:
```python
import pytest
@pytest.mark.unit
def test_calculate_total():
...
@pytest.mark.integration
def test_database_connection():
...
```
## 參考資源
參見技能 (Skill)`python-testing`,獲取詳細的 pytest 模式與 Fixtures。