<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 29, 2018 at 12:55 PM Wouter Overmeire &lt;<a href="mailto:lodagro@gmail.com">lodagro@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">  <br></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>- How to handle reporting? Is there a way to save report per test, so while running and not postpone report generation up to the end?</div></div></blockquote><div><br></div></span><div>Saving the report object is a little tricky (for example pytest-xdist does it manually[1]). Why do you want to do this? </div></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>In the end I want a report on each test. If a run is aborted out of pytest control, there is no report available on the already completed tests, since pytest generates a report when all tests are completed. I would like to save a report on a test once a test is completed.</div></div></div></div></blockquote><div><br></div><div>Actually pytest triggers a `pytest_runtest_logreport` for each test phase (setup, call, teardown). You can implement that hook so you remove passed tests from a list of &quot;lastpassed&quot; from the cache, similarly to how --last-failed works. This should cover your use case of the run being interrupted out of pytest&#39;s control because whenever you execute `cache.set` it will write the cache value to disk.</div><div><br></div><div>In summary my suggestion is:</div><div><br></div><div>1. During `pytest_collection_modifyitems()`, if your plugin is active, get the `lastpassed` list from the cache and remove all tests whose node id is in it.</div><div>2. During each `pytest_runtest_logreport()`, if the test passed, save its node id to the `lastpassed` list.</div><div><br></div><div>You can take a look at `_pytest/cacheprovider.py` for inspiration as well. </div><div><br></div><div>Cheers,</div></div></div>