从代码中访问Pytest通过/失败计数(测试统计数据)

时间:2016-05-13 03:24:17

标签: python-2.7 pytest

使用

在python代码中调用pytest时,有没有办法捕获测试统计数据(pass / fail / xfail / skipped)计数
exit_code = pytest.main()

一旦pytest完成测试,我想收集这些统计数据以便进一步处理。我现在想的就是编写插件并访问" terminalreporter "插件统计数据,但如果有更好,更简单的方法,我很想知道。

1 个答案:

答案 0 :(得分:0)

不是一个很好的解决方案(imho),但似乎有效 具有运行/通过/失败的计数器并使用public function updateUserData($sessionId, $first_name, $last_name, $email) { $result = $this->_instance->executeQuery(' UPDATE users SET email=?, first_name=?, last_name=? WHERE users_id=?' , array($email, ucfirst($first_name), ucfirst($last_name), $sessionId) ); if($result){ Session::set('detailsUpdated', '<div class="alert alert-success"><strong>Succes! </strong>Your details have been updated!</div'); Redirect::to('profile.php'); } } 挂钩

递增
pytest_runtest_logreport(self,report)