python中debug怎么测试循环_如何在中调用“debug”方法py.测试万一发生故障?

最棘手的部分是将测试结果传递到fixture中,其余的几乎是微不足道的。在pytest的示例Making test result information available in fixtures之后,在conftest.py中添加一个自定义钩子:import pytest

@pytest.hookimpl(hookwrapper=True, tryfirst=True)

def pytest_runtest_makereport(item, call):

outcome = yield

rep = outcome.get_result()

setattr(item, "rep_" + rep.when, rep)

return rep

现在,您可以使用自定义拆卸逻辑增强driver装置,以防测试失败:

^{pr2}$

运行测试会产生:$ pytest -sv

=============================== test session starts ===============================

platform darwin Python 3.6.3, ...

cachedir: .cache

rootdir: /Users/hoefling/projects/private/stackoverflow/so-48521762, inifile:

plugins: ...

collecting ... collected 2 items

test_spam.py::test_fail FAILED [ 50%]

debug Server Not Found

test_spam.py::test_ok PASSED [100%]

==================================== FAILURES =====================================

____________________________________ test_fail ____________________________________

driver =

...

- Captured log setup

remote_connection.py 474 DEBUG POST http://127.0.0.1:50319/session { ...

...

remote_connection.py 561 DEBUG Finished Request

======================== 1 failed, 1 passed in 7.23 seconds =======================

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值