Skip to content

Commit 6753063

Browse files
committed
1 parent 3d0f102 commit 6753063

7 files changed

Lines changed: 28 additions & 20 deletions

File tree

src/ert/gui/tools/event_viewer/panel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def add_gui_log_handler() -> Iterator[GUILogHandler]:
9292

9393
gui_handler = GUILogHandler()
9494
logger.addHandler(gui_handler.handler)
95-
96-
yield gui_handler
97-
98-
logger.removeHandler(gui_handler.handler)
95+
try:
96+
yield gui_handler
97+
finally:
98+
logger.removeHandler(gui_handler.handler)

tests/ert/ui_tests/gui/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ def _open_main_window(path) -> Iterator[tuple[ErtMainWindow, Storage, ErtConfig]
104104
add_gui_log_handler() as log_handler,
105105
):
106106
gui = _setup_main_window(config, args_mock, log_handler, config.ens_path)
107-
yield gui, config.ens_path, config
108-
gui.close()
107+
try:
108+
yield gui, config.ens_path, config
109+
finally:
110+
gui.close()
109111

110112

111113
@pytest.fixture

tests/ert/ui_tests/gui/test_breakthrough_visualization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ def open_plotter(config: ErtConfig, qtbot: QtBot):
113113

114114
qtbot.mouseClick(button_plot_tool, Qt.MouseButton.LeftButton)
115115
plot_window = get_child(gui, PlotWindow)
116-
117-
yield plot_window
118-
119-
plot_window.close()
116+
try:
117+
yield plot_window
118+
finally:
119+
plot_window.close()
120120

121121

122122
def setup_storage(config):

tests/ert/ui_tests/gui/test_restart_no_responses_and_parameters.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def _open_main_window(
6868
# RuntimeError: wrapped C/C++ object of type GUILogHandler
6969
handler = GUILogHandler()
7070
gui = _setup_main_window(config, args_mock, handler, config.ens_path)
71-
yield gui, config.ens_path, config
72-
gui.close()
71+
try:
72+
yield gui, config.ens_path, config
73+
finally:
74+
gui.close()
7375

7476

7577
@pytest.fixture

tests/ert/ui_tests/gui/test_workflow_tool.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ def _open_main_window(
4141
# RuntimeError: wrapped C/C++ object of type GUILogHandler
4242
handler = GUILogHandler()
4343
gui = _setup_main_window(config, args_mock, handler, config.ens_path)
44-
yield gui
45-
gui.close()
44+
try:
45+
yield gui
46+
finally:
47+
gui.close()
4648

4749

4850
@pytest.fixture

tests/ert/unit_tests/dark_storage/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ def dark_storage_app_(monkeypatch):
8181
monkeypatch.setenv("ERT_STORAGE_NO_TOKEN", "yup")
8282
monkeypatch.setenv("ERT_STORAGE_ENS_PATH", "storage")
8383

84-
yield app
85-
reset_dark_storage()
84+
try:
85+
yield app
86+
finally:
87+
reset_dark_storage()
8688

8789

8890
@pytest.fixture

tests/ert/unit_tests/resources/test_shell.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
def pushd(path):
2121
cwd0 = Path.cwd()
2222
os.chdir(path)
23-
24-
yield
25-
26-
os.chdir(cwd0)
23+
try:
24+
yield
25+
finally:
26+
os.chdir(cwd0)
2727

2828

2929
symlink = import_from_location(

0 commit comments

Comments
 (0)