diff --git a/deluge/tests/common.py b/deluge/tests/common.py index b5941568d3..af221de2d5 100644 --- a/deluge/tests/common.py +++ b/deluge/tests/common.py @@ -11,6 +11,7 @@ import traceback import pytest +import pytest_twisted from twisted.internet import defer, protocol, reactor from twisted.internet.defer import Deferred from twisted.internet.error import CannotListenError @@ -130,7 +131,7 @@ def outConnectionLost(self): # NOQA: N802 with open(self.logfile, 'w') as f: f.write(self.log_output) - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def kill(self): """Kill the running process. @@ -296,7 +297,7 @@ def start_core( if extra_callbacks: callbacks.extend(extra_callbacks) - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def shutdown_daemon(): username, password = get_localhost_auth() client = Client() diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index 707570f174..56dba574fd 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -5,7 +5,7 @@ # import pytest -from twisted.internet import defer +import pytest_twisted from twisted.internet.error import CannotListenError import deluge.component as component @@ -29,7 +29,7 @@ def terminate_core(self, *args): d = self.core.kill() return d - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def start_core( self, arg, diff --git a/deluge/tests/test_maybe_coroutine.py b/deluge/tests/test_maybe_coroutine.py index afaf171ba2..302b3f888b 100644 --- a/deluge/tests/test_maybe_coroutine.py +++ b/deluge/tests/test_maybe_coroutine.py @@ -6,19 +6,19 @@ import pytest import pytest_twisted import twisted.python.failure -from twisted.internet import defer, reactor, task +from twisted.internet import reactor, task from twisted.internet.defer import maybeDeferred from deluge.decorators import maybe_coroutine -@defer.inlineCallbacks +@pytest_twisted.inlineCallbacks def inline_func(): result = yield task.deferLater(reactor, 0, lambda: 'function_result') return result -@defer.inlineCallbacks +@pytest_twisted.inlineCallbacks def inline_error(): raise Exception('function_error') yield @@ -35,13 +35,13 @@ async def coro_error(): raise Exception('function_error') -@defer.inlineCallbacks +@pytest_twisted.inlineCallbacks def coro_func_from_inline(): result = yield coro_func() return result -@defer.inlineCallbacks +@pytest_twisted.inlineCallbacks def coro_error_from_inline(): result = yield coro_error() return result diff --git a/deluge/tests/test_ui_entry.py b/deluge/tests/test_ui_entry.py index b0948f4672..0f77ab3ab4 100644 --- a/deluge/tests/test_ui_entry.py +++ b/deluge/tests/test_ui_entry.py @@ -13,7 +13,6 @@ import pytest import pytest_twisted -from twisted.internet import defer import deluge import deluge.component as component @@ -353,7 +352,8 @@ def test_console_command_add(self): fd = StringFileDescriptor(sys.stdout) self.patch(sys, 'stdout', fd) - yield self.exec_command() + with mock.patch('deluge.ui.console.main.ConsoleUI.quit', autospec=True): + yield self.exec_command() std_output = fd.out.getvalue() assert ( @@ -377,7 +377,8 @@ def test_console_command_add_move_completed(self): fd = StringFileDescriptor(sys.stdout) self.patch(sys, 'stdout', fd) - yield self.exec_command() + with mock.patch('deluge.ui.console.main.ConsoleUI.quit', autospec=True): + yield self.exec_command() std_output = fd.out.getvalue() assert std_output.endswith( @@ -391,19 +392,22 @@ async def test_console_command_status(self): self.patch_arg_command(['status']) self.patch(sys, 'stdout', fd) - await self.exec_command() + with mock.patch('deluge.ui.console.main.ConsoleUI.quit', autospec=True): + await self.exec_command() std_output = fd.out.getvalue() assert std_output.startswith('Total upload: ') assert std_output.endswith(' Moving: 0\n') - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def test_console_command_config_set_download_location(self): fd = StringFileDescriptor(sys.stdout) self.patch_arg_command(['config --set download_location /downloads']) self.patch(sys, 'stdout', fd) - yield self.exec_command() + with mock.patch('deluge.ui.console.main.ConsoleUI.quit', autospec=True): + yield self.exec_command() + std_output = fd.out.getvalue() assert std_output.startswith('Setting "download_location" to: \'/downloads\'') assert std_output.endswith('Configuration value successfully updated.\n') diff --git a/deluge/tests/test_web_api.py b/deluge/tests/test_web_api.py index eac7163770..695d60aec8 100644 --- a/deluge/tests/test_web_api.py +++ b/deluge/tests/test_web_api.py @@ -11,7 +11,7 @@ import pytest import pytest_twisted -from twisted.internet import defer, reactor +from twisted.internet import reactor from twisted.web.client import Agent, FileBodyProducer from twisted.web.http_headers import Headers from twisted.web.static import File @@ -45,7 +45,7 @@ def on_connect(result): def test_disconnect(self): d = self.deluge_web.web_api.connect(self.host_id) - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def on_connect(result): assert self.deluge_web.web_api.connected() yield self.deluge_web.web_api.disconnect() @@ -76,7 +76,7 @@ def test_set_config(self): assert config['pwd_sha1'] != web_config['pwd_sha1'] assert config['sessions'] != web_config['sessions'] - @defer.inlineCallbacks + @pytest_twisted.inlineCallbacks def get_host_status(self): host = list(self.deluge_web.web_api.hostlist.get_host_info(self.host_id)) host[3] = 'Online' diff --git a/requirements-ci.txt b/requirements-ci.txt index 9e6f4e5dd1..efc66a4118 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -1,4 +1,4 @@ -r requirements.txt -r requirements-tests.txt -pytest==7.4.2 +pytest libtorrent==2.0.7