File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change
1
+ import warnings
2
+ from collections .abc import Iterator
1
3
from pathlib import Path
2
4
from typing import TYPE_CHECKING
3
5
from unittest .mock import patch
15
17
16
18
# to create a new CMMCorePlus() for every test
17
19
@pytest .fixture (autouse = True )
18
- def global_mmcore ():
20
+ def global_mmcore () -> Iterator [ CMMCorePlus ] :
19
21
mmc = CMMCorePlus ()
20
22
mmc .loadSystemConfiguration (TEST_CONFIG )
21
23
with patch .object (_mmcore_plus , "_instance" , mmc ):
22
24
yield mmc
23
25
24
26
25
27
@pytest .fixture (autouse = True )
26
- def _run_after_each_test (request : "FixtureRequest" , qapp : "QApplication" ):
28
+ def _run_after_each_test (
29
+ request : "FixtureRequest" , qapp : "QApplication"
30
+ ) -> Iterator [None ]:
27
31
"""Run after each test to ensure no widgets have been left around.
28
32
29
33
When this test fails, it means that a widget being tested has an issue closing
@@ -51,4 +55,8 @@ def _run_after_each_test(request: "FixtureRequest", qapp: "QApplication"):
51
55
return
52
56
53
57
test = f"{ request .node .path .name } ::{ request .node .originalname } "
54
- raise AssertionError (f"topLevelWidgets remaining after { test !r} : { remaining } " )
58
+ warnings .warn (
59
+ f"topLevelWidgets remaining after { test !r} : { remaining } " ,
60
+ UserWarning ,
61
+ stacklevel = 2 ,
62
+ )
You can’t perform that action at this time.
0 commit comments