Skip to content

Commit a4bf43f

Browse files
committed
FIX: Flake [skip circle]
1 parent 8720d20 commit a4bf43f

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

mne/conftest.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def pytest_configure(config: pytest.Config):
9595
"ultraslowtest: mark a test as ultraslow or to be run rarely",
9696
"pgtest: mark a test as relevant for mne-qt-browser",
9797
"pvtest: mark a test as relevant for pyvistaqt",
98-
"allow_unclosed: allow unclosed pyvistaqt instances",
9998
):
10099
config.addinivalue_line("markers", marker)
101100

@@ -1258,18 +1257,16 @@ def nirx_snirf(request):
12581257

12591258

12601259
@pytest.fixture
1261-
def qt_windows_closed(request, qapp, qtbot):
1260+
def qt_windows_closed(request, qapp):
12621261
"""Ensure that no new Qt windows are open after a test."""
12631262
_check_skip_backend("pyvistaqt")
12641263
qapp.processEvents()
12651264
gc.collect()
12661265
n_before = len(qapp.topLevelWidgets())
1267-
marks = set(mark.name for mark in request.node.iter_markers())
12681266
yield
1269-
qapp.processEvents()
1267+
for _ in range(2):
1268+
qapp.processEvents()
12701269
gc.collect()
1271-
if "allow_unclosed" in marks:
1272-
return
12731270
# Don't check when the test fails
12741271
if not _test_passed(request):
12751272
return

mne/viz/backends/_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ def dec(meth, splash=splash, always_close=always_close):
388388
def func(self, *args, **kwargs):
389389
close_splash = always_close
390390
error = False
391+
if not self:
392+
return
391393
try:
392394
meth(self, *args, **kwargs)
393395
except Exception:
@@ -402,7 +404,9 @@ def func(self, *args, **kwargs):
402404
try:
403405
for n in attr.split(".")[:-1]:
404406
parent = getattr(parent, n)
405-
if name:
407+
if not parent:
408+
break
409+
if parent and name:
406410
widget = getattr(parent, name, False)
407411
else: # empty string means "self"
408412
widget = parent
@@ -416,6 +420,8 @@ def func(self, *args, **kwargs):
416420
delattr(parent, name)
417421
except Exception:
418422
pass
423+
finally:
424+
del parent, attr, do_close
419425

420426
return func
421427

0 commit comments

Comments
 (0)