Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7764 from drew2a/fix/6345
Fix "ValueError: relative path can't be expressed as a file URI"
- Loading branch information
Showing
2 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from unittest.mock import Mock, patch | ||
|
||
import pytest | ||
from PyQt5.QtWidgets import QFileDialog | ||
|
||
from tribler.gui.tribler_window import TriblerWindow | ||
|
||
|
||
# pylint: disable=redefined-outer-name | ||
@pytest.fixture | ||
def tribler_window(): | ||
""" Create mocked TriblerWindow instance""" | ||
with patch('tribler.gui.tribler_window.TriblerWindow.__init__', Mock(return_value=None)): | ||
window = TriblerWindow(Mock(), Mock(), Mock(), Mock()) | ||
window.pending_uri_requests = [] | ||
return window | ||
|
||
|
||
def test_on_add_torrent_browse_file(tribler_window: TriblerWindow): | ||
""" Test that the on_add_torrent_browse_file method works correctly""" | ||
tribler_window.raise_window = Mock() | ||
tribler_window.process_uri_request = Mock() | ||
|
||
with patch.object(QFileDialog, 'getOpenFileNames', Mock(return_value=['.'])) as patched_getOpenFileNames: | ||
tribler_window.on_add_torrent_browse_file() | ||
|
||
assert tribler_window.raise_window.called | ||
assert patched_getOpenFileNames.called | ||
assert tribler_window.process_uri_request.called |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters