網站首頁 編程語言 正文
運行一個簡單的用例:
#cd code/ch1/test_one.py
def test_passing():
assert (1, 2, 3) == (1, 2, 3)
運行結果及說明:
測試運行可能出現的結果總結(上圖6、7運行結果列舉)
類型(7) | 表示(6) | 說明 |
---|---|---|
PASSED | . | 測試通過 |
FAILED | F | 測試失敗(fail或xpass與strict沖突造成的失敗) |
SKIPPED | s | 測試未被執行 |
xfail | x | 預計測試失敗,并且確實失敗 |
XPASS | X | 預計測試失敗,但實際上運行通過,不符合預期 |
ERROR | E | 測試用例之外的觸發代碼異常 |
示例:
import pytest
#測試通過
def test_passing():
assert (1, 2, 3) == (1, 2, 3)
#測試失敗
def test_failing():
assert (1, 2, 3) == (3, 2, 1)
#跳過不執行
@pytest.mark.skip()
def test_skip():
assert (1, 2, 3) == (3, 2, 1)
#預期失敗,確實失敗
@pytest.mark.xfail()
def test_xfail():
assert (1, 2, 3) == (3, 2, 1)
#預期失敗,但是結果pass
@pytest.mark.xfail()
def test_xpass():
assert (1, 2, 3) == (1, 2, 3)
運行結果:
原文鏈接:https://blog.csdn.net/totorobig/article/details/111775014
相關推薦
- 2022-10-15 Nginx如何配置加密證書訪問實現_nginx
- 2022-07-21 TensorRT之mmdeploy使用
- 2022-09-21 Flutter實現底部和頂部導航欄_Android
- 2022-05-18 C語言實現學生宿舍信息管理系統_C 語言
- 2022-04-11 【Android,kotlin】寫倒計時CountDown的正確姿勢
- 2022-06-19 LINQ基礎之Intersect、Except和Distinct子句_C#教程
- 2022-07-01 python神經網絡Keras實現GRU及其參數量_python
- 2023-01-18 pip?search報錯問題及解決_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支