[pytest-dev] Session state

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Nov 14 18:34:15 EST 2016


Dear Pytest-Dev,

I am trying to implement a pytest plugin to check for reference leaks
similarly to how it is done in CPython with python -mtest -R : command.

The problem is that pytest_runtest_protocol seems to update some internal
state and calling it even on an empty test function increases the total
reference count.  Clearly, I need to clean up the internal state in my
plugin, but I cannot figure out where this state is kept.

Looking at the  pytest_runtest_protocol implementation in runner.py, I see
the following code:

def pytest_runtest_protocol(item, nextitem):
    ...
    runtestprotocol(item, nextitem=nextitem)
    return True

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20161114/1924a2dd/attachment.html>


More information about the pytest-dev mailing list