39 lines
647 B
Markdown
39 lines
647 B
Markdown
---
|
||
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。
|