From 77a1db27cde2eea21efc34f7ad9612415eb8eaa7 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 8 Jul 2020 15:58:06 -0300 Subject: [PATCH] Fix compatibility with pytest master Fix the autouse fixture which diverts atexit.register calls to support the correct signature. --- testing/conftest.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/testing/conftest.py b/testing/conftest.py index 66fbac6..43c0399 100644 --- a/testing/conftest.py +++ b/testing/conftest.py @@ -22,12 +22,16 @@ def _divert_atexit(request, monkeypatch): finalizers = [] - def finish(): - while finalizers: - finalizers.pop()() + def fake_register(func, *args, **kwargs): + finalizers.append((func, args, kwargs)) - monkeypatch.setattr(atexit, "register", finalizers.append) - request.addfinalizer(finish) + monkeypatch.setattr(atexit, "register", fake_register) + + yield + + while finalizers: + func, args, kwargs = finalizers.pop() + func(*args, **kwargs) def pytest_addoption(parser):