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

39 lines
647 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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。