def yield_and_report(item, when, log=True, **kwds): call = call_runtest_hook(item, when, **kwds) call.when = 'yield' hook = item.ihook report = hook.pytest_runtest_makereport(item=item, call=call) report.call_result = getattr(item, 'call_result', None) if not item.was_finished and report.passed and not isinstance( report.call_result, Report): log = False if log: hook.pytest_runtest_logreport(report=report) if check_interactive_exception(call, report): hook.pytest_exception_interact(node=item, call=call, report=report) return report
def call_and_report(self, item, when, log=True, **kwds): """ Monkey patched from the runner plugin. Responsible for running the test and reporting the outcome. Had to be patched to avoid reporting about test retries. :param item: pytest wrapper for the test function to be run :type item: :class:`Function` :param when: The stage of the test being run. Usually one of 'setup', 'call', 'teardown'. :type when: `str` :param log: Whether or not to report the test outcome. Ignored for test retries; flaky doesn't report test retries, only the final outcome. :type log: `bool` """ call = call_runtest_hook(item, when, **kwds) self._call_infos[item][when] = call hook = item.ihook report = hook.pytest_runtest_makereport(item=item, call=call) # Start flaky modifications # only retry on call, not setup or teardown if report.when == self._PYTEST_WHEN_CALL: if report.outcome == self._PYTEST_OUTCOME_PASSED: if self._should_handle_test_success(item): log = False elif report.outcome == self._PYTEST_OUTCOME_FAILED: err, name = self._get_test_name_and_err(item) if self._will_handle_test_error_or_failure(item, name, err): log = False # End flaky modifications if log: hook.pytest_runtest_logreport(report=report) if self.runner.check_interactive_exception(call, report): hook.pytest_exception_interact(node=item, call=call, report=report) return report