Skip to content

Commit

Permalink
Mock a static method in tests to prevent freezing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsavol committed Jul 30, 2024
1 parent 35e6e0b commit 247ce5a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/mock_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ def qsettings_value_side_effect(key, defaultValue="0"):
def create_toolboxui():
"""Returns ToolboxUI, where QSettings among others has been mocked."""
with patch("spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), patch(
"spinetoolbox.ui_main.QSettings.value"
) as mock_qsettings_value:
"spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value, 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 @@ -113,15 +114,14 @@ def create_toolboxui_with_project(project_dir):
"""Returns ToolboxUI with a project instance where
QSettings among others has been mocked."""
with patch("spinetoolbox.ui_main.ToolboxUI.save_project"), patch(
"spinetoolbox.ui_main.QSettings.value"
) as mock_qsettings_value, patch("spinetoolbox.ui_main.QSettings.setValue"), patch(
"spinetoolbox.ui_main.QSettings.sync"
), patch(
"spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"
), patch(
"spinetoolbox.ui_main.QScrollArea.setWidget"
):
"spinetoolbox.ui_main.QSettings.value") as mock_qsettings_value, patch(
"spinetoolbox.ui_main.ToolboxUI.set_app_style") as mock_set_app_style, patch(
"spinetoolbox.ui_main.QSettings.setValue"), patch(
"spinetoolbox.ui_main.QSettings.sync"), patch(
"spinetoolbox.plugin_manager.PluginManager.load_installed_plugins"), 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 247ce5a

Please sign in to comment.