pytest前后置函数setup、teardown和fixture执行结果规则

三个阶段

  • setup:前置
  • call:步骤
  • teardown:后置

前后置函数与fixture前后置结果规则一致。

只有setup异常

各阶段结果

  • setup: failed
  • call: 跳过不执行
  • teardown: passed,未执行代码

用例结果:1 error

只有test_a()异常

各阶段结果

  • setup: passed
  • call: 1 failed
  • teardown: passed

用例结果:failed

只有teardown异常

各阶段结果

  • setup: passed
  • call: passed
  • teardown: failed

用例结果:1 passed, 1 error

posted @ 2022-08-13 23:28  强哥不强  阅读(259)  评论(0)    收藏  举报