On Tue, Nov 22, 2016 at 8:10 AM, Bruno Oliveira <[email protected]> wrote:
> > Not sure who is keeping extra references around, ... I have figured out this part. The problem was that I originally [0] did reference counting around a call to item.runtest() which may create new objects by interacting with features and those objects persist until a teardown call. Now I do refcount in the pytest_runtest_protocol hook [1], but this leaves open the issue of passing the reports to the runner's hooks. >> where runtestprotocol() is a function returning a list to reports, but this list is apparently discarded by the runner. Can someone explain how reports are passed from the runner hooks to the terminal hooks? > > > The hook implemented by the terminal plugin is pytest_runtest_logreport. > > That is called by the runner itself: > > def call_and_report(item, when, log=True, **kwds): > call = call_runtest_hook(item, when, **kwds) > hook = item.ihook > report = hook.pytest_runtest_makereport(item=item, call=call) > 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 > I am not sure how I can use a similar logic in my code. As a work-around, I am storing leaks reports in a global nodeid:rep dictionary which I process in pytest_report_teststatus and pytest_terminal_summary hooks. Is there a better way to do this? Another open issue is what to do with the fixtures having wider than "function" scope. Notwithstanding the remaining issues, my plugin works now with Python 3.5 and I have found one reference leak in my own code (together with 2 false positives one of which was a poorly written test). I have published [2] my plugin as pytest-leaks on PyPI and hopefully others will find it useful. Any comments or suggestions are most welcome. [0]: https://github.com/abalkin/pytest-leaks/blob/v0.1.0/pytest_leaks.py#L103 [1]: https://github.com/abalkin/pytest-leaks/blob/v0.2.0/pytest_leaks.py#L71 [2]: https://pypi.python.org/pypi/pytest-leaks
_______________________________________________ pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
