File: conftest.py

package info (click to toggle)
pytest-forked 1.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 220 kB
  • sloc: python: 283; makefile: 6; sh: 4
file content (21 lines) | stat: -rw-r--r-- 434 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import pytest


pytest_plugins = "pytester"


@pytest.fixture(autouse=True)
def _divert_atexit(request, monkeypatch):
    import atexit

    atexit_fns = []

    def atexit_register(func, *args, **kwargs):
        atexit_fns.append(lambda: func(*args, **kwargs))

    def finish():
        while atexit_fns:
            atexit_fns.pop()()

    monkeypatch.setattr(atexit, "register", atexit_register)
    request.addfinalizer(finish)