視頻來源:B站《冒死上傳!pytest接口自動化測試框架(基礎理論到項目實戰及二次開發)教學視頻【軟件測試】》
一邊學習一邊整理老師的課程內容及試驗筆記,並與大家分享,侵權即刪,謝謝支持!
附上匯總貼:pytest接口自動化測試框架 | 匯總_COCOgsta的博客-CSDN博客
pytest --showlocals # show local variables in tracebacks
pytest -I # show local variables(shortcut)
pytest --tb=auto # (default) 'long' tracebacks for the first and last entry, but 'short' style for the other entries
pytest --tb=long # exhaustive, informative traceback formatting
pytest --tb=short # shorter traceback format
pytest --tb=line # only one line per failure
pytest --tb=no # no traceback at all
--full-trace 參數會打印更多的錯誤輸出信息,比參數--tb=long還多,即使是Ctrl+C觸發的錯誤,也會打印出來
import pytest
def test_1():
print('\n用例1執行成功')
def test_2():
a = 1
# 增加一個報錯
assert a == 2
if __name__ == '__main__':
pytest.main(['--full-trace','-s', 'test_traceback.py'])