[Tests] Fix save_resume_data errors in test_torrent

Error in test_rename_unicode:

   TypeError: object MagicMock can't be used in 'await' expression

Fixed by using AsyncMock that can be awaited.
Added backport asyncmock for Python 3.7
This commit is contained in:
Calum Lind 2023-02-28 14:15:11 +00:00
parent 9ce8afe507
commit e70a983a55
No known key found for this signature in database
GPG Key ID: 90597A687B836BA3
2 changed files with 7 additions and 1 deletions

View File

@ -25,6 +25,11 @@ from deluge.core.rpcserver import RPCServer
from deluge.core.torrent import Torrent
from deluge.core.torrentmanager import TorrentManager, TorrentState
try:
from unittest.mock import AsyncMock
except ImportError:
from mock import AsyncMock
class TestTorrent(BaseTestCase):
def setup_config(self):
@ -340,7 +345,7 @@ class TestTorrent(BaseTestCase):
handle = self.session.add_torrent(atp)
self.torrent = Torrent(handle, {})
# Ignore TorrentManager method call
TorrentManager.save_resume_data = mock.MagicMock
TorrentManager.save_resume_data = AsyncMock()
result = self.torrent.rename_folder('unicode_filenames', 'Горбачёв')
assert isinstance(result, defer.DeferredList)

View File

@ -9,3 +9,4 @@ flake8-isort
pep8-naming
mccabe
pylint
asyncmock; python_version <= '3.7'