Skip to content

Commit

Permalink
Adjust test_show_system_popup_win to accommodate multiple runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Jun 28, 2023
1 parent 9fa0386 commit f058f74
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tribler/core/utilities/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ def test_show_system_popup_win():
# In case of *nix machine, "@patch_import(modules=['win32api'], MessageBox=MagicMock())" will work.
# In case of win machine, "with patch('win32api.MessageBox'):" will work.
#
# No matter what kind of Mock was used, the line "win32api.MessageBox.assert_called_once()" should work.
# No matter what kind of Mock was used, the line "win32api.MessageBox.assert_called_with()" should work.
#
# This approach also applies to the test functions below.

import win32api

with patch('win32api.MessageBox'): # this patch starts to work only in case win32api exists on the target machine
show_system_popup('title', 'text')
win32api.MessageBox.assert_called_once_with(0, 'text', 'title')
win32api.MessageBox.assert_called_with(0, 'text', 'title')


@patch_import(modules=['subprocess'], Popen=MagicMock())
Expand Down

0 comments on commit f058f74

Please sign in to comment.