[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:
parent
9ce8afe507
commit
e70a983a55
|
@ -25,6 +25,11 @@ from deluge.core.rpcserver import RPCServer
|
||||||
from deluge.core.torrent import Torrent
|
from deluge.core.torrent import Torrent
|
||||||
from deluge.core.torrentmanager import TorrentManager, TorrentState
|
from deluge.core.torrentmanager import TorrentManager, TorrentState
|
||||||
|
|
||||||
|
try:
|
||||||
|
from unittest.mock import AsyncMock
|
||||||
|
except ImportError:
|
||||||
|
from mock import AsyncMock
|
||||||
|
|
||||||
|
|
||||||
class TestTorrent(BaseTestCase):
|
class TestTorrent(BaseTestCase):
|
||||||
def setup_config(self):
|
def setup_config(self):
|
||||||
|
@ -340,7 +345,7 @@ class TestTorrent(BaseTestCase):
|
||||||
handle = self.session.add_torrent(atp)
|
handle = self.session.add_torrent(atp)
|
||||||
self.torrent = Torrent(handle, {})
|
self.torrent = Torrent(handle, {})
|
||||||
# Ignore TorrentManager method call
|
# Ignore TorrentManager method call
|
||||||
TorrentManager.save_resume_data = mock.MagicMock
|
TorrentManager.save_resume_data = AsyncMock()
|
||||||
|
|
||||||
result = self.torrent.rename_folder('unicode_filenames', 'Горбачёв')
|
result = self.torrent.rename_folder('unicode_filenames', 'Горбачёв')
|
||||||
assert isinstance(result, defer.DeferredList)
|
assert isinstance(result, defer.DeferredList)
|
||||||
|
|
|
@ -9,3 +9,4 @@ flake8-isort
|
||||||
pep8-naming
|
pep8-naming
|
||||||
mccabe
|
mccabe
|
||||||
pylint
|
pylint
|
||||||
|
asyncmock; python_version <= '3.7'
|
||||||
|
|
Loading…
Reference in New Issue