[TIP] resume an interrupted pytest test run

Bruno Oliveira nicoddemus at gmail.com
Mon Jan 29 06:19:59 PST 2018


Hi Wouter,

On Mon, Jan 29, 2018 at 10:58 AM Wouter Overmeire <lodagro at gmail.com> wrote:

> I have something basic running now. Save nodeids of all test tests to be
> run (pytest_collection_modifyitems) and test by test store the nodeids
> (pytest_runtest_makereport) of the completed tests. When restarting pytest
> using plugin specific flag the already completed tests will be marked
> *pytest.mark.skip*.
>

Another way of implementing this is to remove the tests which passed in the
previous pytest run during `pytest_collection_modifyitems`; that's how the
-m, -k, --lf and --ff command-line options work.

Two questions:
> - What is *pytest*-way of stopping a run from within a plugin and
> informing the user why? I now raise an exception, which is show as an
> INTERNALERROR.
>

You can use `pytest.exit(msg)` for that.


> - 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?
>

Saving the report object is a little tricky (for example pytest-xdist does
it manually[1]). Why do you want to do this?

Cheers,


>
> 2018-01-24 15:37 GMT+01:00 Bruno Oliveira <nicoddemus at gmail.com>:
>
>> Hi Wouter,
>>
>> Currently there's no support for that, but I imagine to implement a
>> plugin to do that should be relatively easy if you are inclined to. :)
>>
>> If you go with the route of implementing a plugin, feel free to ask for
>> advice on IRC[1] or creating an issue with your questions in the pytest bug
>> tracker [2].
>>
>> Cheers,
>> Bruno
>>
>> [1] https://docs.pytest.org/en/latest/contact.html
>> [2] https://github.com/pytest-dev/pytest/issues
>>
>> On Wed, Jan 24, 2018 at 12:10 PM Wouter Overmeire <lodagro at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> How can I resume an interrupted pytest test run?
>>>
>>> Suppose using command line arguments I select a number of tests to be
>>> run by pytest. The tests take a while and in the middle of the run there is
>>> an issue (for example a power outage) and pytest was stopped. Is it
>>> possible to resume an interrupted run?
>>>
>>> The idea is not to rerun the failed tests, but to run only those tests
>>> that did not run in the first run.
>>>
>>> Wouter
>>> _______________________________________________
>>> testing-in-python mailing list
>>> testing-in-python at lists.idyll.org
>>> http://lists.idyll.org/listinfo/testing-in-python
>>>
>>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180129/7c0123f6/attachment.htm>


More information about the testing-in-python mailing list