[py-dev] how to access docstrings from pytest_report_teststatus or pytest_runtest_logreport

Anton P anton7811 at gmail.com
Thu Feb 16 13:48:15 CET 2012


Hi,

I'm trying to write my own py.test pluging for extended junitxml
reports. This pluging have to parse testcase's docstrings for some
additional info for report.

I've found the next code in pytest_bugzilla plugin:

    def pytest_report_teststatus(self,report):
        if report.failed:
            if self.analysed(report.item.function.__doc__):
                return "analysed", "A", "ANALYSED"

And I've tried to do the same to access docstrings. But I'm confused,
because report object does not contain "item" attribute.

At the moment I've added class ExtTestReport(TestReport) and redefined
pytest_runtest_makereport() in plugin. The last hook now return report
with "item" object.

But I think, that redefining native pytest_runtest_makereport() in
pluging is not the best idea. Especially because new method is always
called regardless of my pluging usage.

Please, point me to right solution to access testcase's docstrings
from pytest_report_teststatus() or pytest_runtest_logreport().

Thank you in advance!



More information about the Pytest-dev mailing list