Hi Nokolaus,

On Wed, Feb 17, 2016 at 7:07 PM Nikolaus Rath <[email protected]> wrote:

> Is there a way to add a delay that is (1) only incurred when a test
> fails and (2) executed right after the test fails (ie., before the capfd
> finalizer runs)?
>

One way to execute something right after the test function is to implement
the pytest_pyfunc_call, which is used to call python test functions:

@pytest.mark.hookwrapper
def pytest_pyfunc_call(pyfuncitem):
    outcome = yield
    failed = outcome.excinfo is not None
    if failed:
        wait_a_moment()

You might even use marks to add this "wait time" only to marked functions,
instead of all tests.

I don't have time to look up and see if this will work with interaction
with the capture plugin, but it's worth a shot.

HTH,
Bruno.
_______________________________________________
pytest-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pytest-dev

Reply via email to