Skip to content

Commit

Permalink
Fix freezing windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsavol committed Jul 30, 2024
1 parent ce15c9e commit 762c177
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/mock_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

def create_toolboxui():
"""Returns ToolboxUI, where QSettings among others has been mocked."""
with mock.patch("spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), mock.patch(
"spinetoolbox.ui_main.QSettings.value"
) as mock_qsettings_value:
with (mock.patch("spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), mock.patch(
"spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value,
mock.patch("spinetoolbox.ui_main.ToolboxUI.set_app_style") as mock_set_app_style):
mock_qsettings_value.side_effect = qsettings_value_side_effect
mock_set_app_style.return_value = True
toolbox = ToolboxUI()
return toolbox

Expand All @@ -41,16 +42,18 @@ def create_project(toolbox, project_dir):
def create_toolboxui_with_project(project_dir):
"""Returns ToolboxUI with a project instance where
QSettings among others has been mocked."""
with mock.patch("spinetoolbox.ui_main.ToolboxUI.save_project"), mock.patch(
with (mock.patch("spinetoolbox.ui_main.ToolboxUI.save_project"), mock.patch(
"spinetoolbox.ui_main.QSettings.value"
) as mock_qsettings_value, mock.patch("spinetoolbox.ui_main.QSettings.setValue"), mock.patch(
) as mock_qsettings_value, mock.patch("spinetoolbox.ui_main.ToolboxUI.set_app_style"
) as mock_set_app_style, mock.patch("spinetoolbox.ui_main.QSettings.setValue"), mock.patch(
"spinetoolbox.ui_main.QSettings.sync"
), mock.patch(
"spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"
), mock.patch(
"spinetoolbox.ui_main.QScrollArea.setWidget"
):
)):
mock_qsettings_value.side_effect = qsettings_value_side_effect
mock_set_app_style.return_value = True
toolbox = ToolboxUI()
toolbox.create_project(project_dir)
return toolbox
Expand Down

0 comments on commit 762c177

Please sign in to comment.