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

Anton P anton7811 at gmail.com
Fri Feb 17 12:25:16 CET 2012


Thank you!

That works for me!

-Anton


2012/2/16 Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>:
> On 02/16/2012 01:48 PM, Anton P wrote:
>>
>> 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().
>>
> you can extend the native pytest_runtest_makereport
>
> think of something like
>
> def pytest_runtest_makereport(__multicall__, ...):
>   rep = __multicall__.execute()
>   rep._docstring = item...
>   return rep
>
> -- Regards Ronny
>
>> Thank you in advance!
>> _______________________________________________
>> py-dev mailing list
>> py-dev at codespeak.net
>> http://codespeak.net/mailman/listinfo/py-dev
>
>



More information about the Pytest-dev mailing list