1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
import os
import pytest
from magicgui.application import use_app
# Disable tqdm's TMonitor thread to prevent race conditions with Qt threading
# that can cause intermittent segfaults on CI (especially with PySide6 on Linux).
# See: https://github.com/tqdm/tqdm/issues/469
try:
from tqdm import tqdm as _tqdm_std
_tqdm_std.monitor_interval = 0
except ImportError:
pass
@pytest.fixture(scope="session")
def qapp():
yield use_app("qt").native
# for now, the only backend is qt, and pytest-qt's qapp provides some nice pre-post
# test cleanup that prevents some segfaults. Once we start testing multiple backends
# this will need to change.
@pytest.fixture(autouse=True, scope="function")
def always_qapp(qapp):
yield qapp
for w in qapp.topLevelWidgets():
w.close()
w.deleteLater()
@pytest.fixture(autouse=True, scope="function")
def _clean_return_callbacks():
from magicgui.type_map import TypeMap
yield
TypeMap.global_instance()._return_callbacks.clear()
|