[pytest-dev] How to add delay before processing captured output
Bruno Oliveira
nicoddemus at gmail.com
Wed Feb 17 20:58:23 EST 2016
Hi Nokolaus,
On Wed, Feb 17, 2016 at 7:07 PM Nikolaus Rath <Nikolaus at rath.org> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20160218/c8ba46b6/attachment.html>
More information about the pytest-dev
mailing list