Skip to content

Commit

Permalink
Merge pull request #7514 from drew2a/fix/test_show_system_popup_win
Browse files Browse the repository at this point in the history
Adjust `test_show_system_popup_win` to accommodate multiple runs.
  • Loading branch information
drew2a authored Jun 28, 2023
2 parents 9fa0386 + f058f74 commit 3b760ab
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 3b760ab

Please sign in to comment.