'handle a setup/call/teardown report, generating the appropriate
xml tags as necessary.
note: due to plugins like xdist, this hook may be called in interlaced
order with reports from other nodes. for example:
usual call order:
-> setup node1
-> call node1
-> teardown node1
-> setup node2
-> call node2
-> teardown node2
possible call order in xdist:
-> setup node1
-> call node1
-> setup node2
-> call node2
-> teardown node2
-> teardown node1'

def pytest_runtest_logreport(self, report):

    close_report = None
    if report.passed:
        if (report.when == 'call'):
            reporter = self._opentestcase(report)
            reporter.append_pass(report)
    elif report.failed:
        if (report.when == 'teardown'):
            report_wid = getattr(report, 'worker_id', None)
            report_ii = getattr(report, 'item_index', None)
            close_report = next((rep for rep in self.open_reports if ((rep.nodeid == report.nodeid) and (getattr(rep, 'item_index', None) == report_ii) and (getattr(rep, 'worker_id', None) == report_wid))), None)
            if close_report:
                self.finalize(close_report)
                self.cnt_double_fail_tests += 1
        reporter = self._opentestcase(report)
        if (report.when == 'call'):
            reporter.append_failure(report)
            self.open_reports.append(report)
        else:
            reporter.append_error(report)
    elif report.skipped:
        reporter = self._opentestcase(report)
        reporter.append_skipped(report)
    self.update_testcase_duration(report)
    if (report.when == 'teardown'):
        reporter = self._opentestcase(report)
        reporter.write_captured_output(report)
        self.finalize(report)
        report_wid = getattr(report, 'worker_id', None)
        report_ii = getattr(report, 'item_index', None)
        close_report = next((rep for rep in self.open_reports if ((rep.nodeid == report.nodeid) and (getattr(rep, 'item_index', None) == report_ii) and (getattr(rep, 'worker_id', None) == report_wid))), None)
        if close_report:
            self.open_reports.remove(close_report)
