aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarDaniel Baumann <daniel@debian.org>2025-03-21 01:38:07 +0100
committerLibravatarDaniel Baumann <daniel@debian.org>2025-03-21 01:38:07 +0100
commit354b8c521e7951f7f332efd62257aebb48d44437 (patch)
tree379c16f78715bcea62016035b3226246e42fbbf6
parentfc269ebcb7a4f2658c0c16e88084c0941777d8bd (diff)
Adding upstream version 2.1.2~dev0+20250301.upstream/2.1.2_dev0+20250301
Signed-off-by: Daniel Baumann <daniel@debian.org>
-rw-r--r--deluge/decorators.py18
-rw-r--r--deluge/tests/test_torrent.py6
-rw-r--r--deluge/tests/test_ui_entry.py35
-rw-r--r--deluge/ui/console/cmdline/commands/rm.py5
-rw-r--r--deluge/ui/gtk3/createtorrentdialog.py2
-rw-r--r--deluge/ui/gtk3/listview.py2
-rw-r--r--deluge/ui/tracker_icons.py9
-rw-r--r--requirements-ci.txt2
8 files changed, 41 insertions, 38 deletions
diff --git a/deluge/decorators.py b/deluge/decorators.py
index 7b1896c..04e1796 100644
--- a/deluge/decorators.py
+++ b/deluge/decorators.py
@@ -196,11 +196,27 @@ class CoroutineDeferred(defer.Deferred):
d = defer.ensureDeferred(self.coro)
d.chainDeferred(self)
- def addCallbacks(self, *args, **kwargs): # noqa: N802
+ def _callback_activate(self):
+ """Verify awaited status before calling activate."""
assert not self.awaited, 'Cannot add callbacks to an already awaited coroutine.'
self.activate()
+
+ def addCallback(self, *args, **kwargs): # noqa: N802
+ self._callback_activate()
+ return super().addCallback(*args, **kwargs)
+
+ def addCallbacks(self, *args, **kwargs): # noqa: N802
+ self._callback_activate()
return super().addCallbacks(*args, **kwargs)
+ def addErrback(self, *args, **kwargs): # noqa: N802
+ self._callback_activate()
+ return super().addErrback(*args, **kwargs)
+
+ def addBoth(self, *args, **kwargs): # noqa: N802
+ self._callback_activate()
+ return super().addBoth(*args, **kwargs)
+
_RetT = TypeVar('_RetT')
diff --git a/deluge/tests/test_torrent.py b/deluge/tests/test_torrent.py
index 6288615..5a298ef 100644
--- a/deluge/tests/test_torrent.py
+++ b/deluge/tests/test_torrent.py
@@ -199,6 +199,8 @@ class TestTorrent(BaseTestCase):
# self.print_priority_list(priorities)
def test_torrent_error_data_missing(self):
+ if VersionSplit(lt.__version__) > VersionSplit('2.0.7.0'):
+ pytest.xfail('Test not working as expected after lt 2.0.7')
options = {'seed_mode': True}
filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename, 'rb') as _file:
@@ -214,6 +216,8 @@ class TestTorrent(BaseTestCase):
self.assert_state_wait(torrent, 'Error')
def test_torrent_error_resume_original_state(self):
+ if VersionSplit(lt.__version__) > VersionSplit('2.0.7.0'):
+ pytest.xfail('Test not working as expected after lt 2.0.7')
options = {'seed_mode': True, 'add_paused': True}
filename = common.get_test_data_file('test_torrent.file.torrent')
with open(filename, 'rb') as _file:
@@ -233,7 +237,7 @@ class TestTorrent(BaseTestCase):
def test_torrent_error_resume_data_unaltered(self):
if VersionSplit(lt.__version__) >= VersionSplit('1.2.0.0'):
- pytest.skip('Test not working as expected on lt 1.2 or greater')
+ pytest.xfail('Test not working as expected on lt 1.2 or greater')
resume_data = {
'active_time': 13399,
diff --git a/deluge/tests/test_ui_entry.py b/deluge/tests/test_ui_entry.py
index b0948f4..38b870d 100644
--- a/deluge/tests/test_ui_entry.py
+++ b/deluge/tests/test_ui_entry.py
@@ -12,8 +12,6 @@ from io import StringIO
from unittest import mock
import pytest
-import pytest_twisted
-from twisted.internet import defer
import deluge
import deluge.component as component
@@ -27,7 +25,6 @@ from deluge.ui import ui_entry
from deluge.ui.web.server import DelugeWeb
from . import common
-from .daemon_base import DaemonBase
DEBUG_COMMAND = False
@@ -70,15 +67,6 @@ class UIBaseTestCase:
return self.var['start_cmd']()
-class UIWithDaemonBaseTestCase(UIBaseTestCase, DaemonBase):
- """Subclass for test that require a deluged daemon"""
-
- def set_up(self):
- d = self.common_set_up()
- common.setup_test_logger(level='info', prefix=self.config_dir / self.id())
- return d
-
-
class TestDelugeEntry(BaseTestCase):
def set_up(self):
return component.start()
@@ -321,13 +309,13 @@ class ConsoleUIBaseTestCase(UIBaseTestCase):
assert 'unrecognized arguments: --ui' in fd.out.getvalue()
-class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
+class ConsoleUIWithDaemonBaseTestCase(UIBaseTestCase):
"""Implement Console tests that require a running daemon"""
def set_up(self):
# Avoid calling reactor.shutdown after commands are executed by main.exec_args()
deluge.ui.console.main.reactor = common.ReactorOverride()
- return UIWithDaemonBaseTestCase.set_up(self)
+ return super().set_up()
def patch_arg_command(self, command):
if isinstance(command, str):
@@ -346,14 +334,13 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
+ command,
)
- @pytest_twisted.inlineCallbacks
- def test_console_command_add(self):
+ async def test_console_command_add(self):
filename = common.get_test_data_file('test.torrent')
self.patch_arg_command([f'add "{filename}"'])
fd = StringFileDescriptor(sys.stdout)
self.patch(sys, 'stdout', fd)
- yield self.exec_command()
+ await self.exec_command()
std_output = fd.out.getvalue()
assert (
@@ -361,8 +348,7 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
== 'Attempting to add torrent: ' + filename + '\nTorrent added!\n'
)
- @pytest_twisted.inlineCallbacks
- def test_console_command_add_move_completed(self):
+ async def test_console_command_add_move_completed(self):
filename = common.get_test_data_file('test.torrent')
tmp_path = 'c:\\tmp' if windows_check() else '/tmp'
self.patch_arg_command(
@@ -377,7 +363,7 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
fd = StringFileDescriptor(sys.stdout)
self.patch(sys, 'stdout', fd)
- yield self.exec_command()
+ await self.exec_command()
std_output = fd.out.getvalue()
assert std_output.endswith(
@@ -397,20 +383,19 @@ class ConsoleUIWithDaemonBaseTestCase(UIWithDaemonBaseTestCase):
assert std_output.startswith('Total upload: ')
assert std_output.endswith(' Moving: 0\n')
- @defer.inlineCallbacks
- def test_console_command_config_set_download_location(self):
+ async 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()
+ await 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')
-@pytest.mark.usefixtures('daemon', 'client')
-class TestConsoleScriptEntryWithDaemon(BaseTestCase, ConsoleUIWithDaemonBaseTestCase):
+@pytest.mark.usefixtures('daemon', 'client', 'base_fixture')
+class TestConsoleScriptEntryWithDaemon(ConsoleUIWithDaemonBaseTestCase):
@pytest.fixture(autouse=True)
def set_var(self, request):
request.cls.var = {
diff --git a/deluge/ui/console/cmdline/commands/rm.py b/deluge/ui/console/cmdline/commands/rm.py
index 4a3fd00..aebe868 100644
--- a/deluge/ui/console/cmdline/commands/rm.py
+++ b/deluge/ui/console/cmdline/commands/rm.py
@@ -9,6 +9,8 @@
import logging
+from twisted.internet import defer
+
import deluge.component as component
from deluge.ui.client import client
@@ -63,7 +65,7 @@ class Command(BaseCommand):
_('Confirm with -c to remove the listed torrents (Count: %d)')
% len(torrent_ids)
)
- return
+ return defer.succeed(True)
def on_removed_finished(errors):
if errors:
@@ -76,6 +78,7 @@ class Command(BaseCommand):
log.info('Removing %d torrents', len(torrent_ids))
d = client.core.remove_torrents(torrent_ids, options.remove_data)
d.addCallback(on_removed_finished)
+ return d
def complete(self, line):
# We use the ConsoleUI torrent tab complete method
diff --git a/deluge/ui/gtk3/createtorrentdialog.py b/deluge/ui/gtk3/createtorrentdialog.py
index e9f1690..ea578a6 100644
--- a/deluge/ui/gtk3/createtorrentdialog.py
+++ b/deluge/ui/gtk3/createtorrentdialog.py
@@ -493,7 +493,7 @@ class CreateTorrentDialog:
*textview_buf.get_bounds(), include_hidden_chars=False
)
log.debug('Create torrent tracker lines: %s', trackers_text)
- self.config['createtorrent.trackers'] = trackers_text.split('/n')
+ self.config['createtorrent.trackers'] = trackers_text.splitlines()
# Append trackers liststore with unique trackers and tiers starting from last tier number.
last_tier, orig_trackers = last_tier_trackers_from_liststore(
diff --git a/deluge/ui/gtk3/listview.py b/deluge/ui/gtk3/listview.py
index a80d795..002c0f8 100644
--- a/deluge/ui/gtk3/listview.py
+++ b/deluge/ui/gtk3/listview.py
@@ -782,7 +782,7 @@ class ListView:
return True
- def on_keypress_search_by_name(self, model, column, key, _iter):
+ def on_keypress_search_by_name(self, model, column, key, _iter, *search_data):
torrent_name_col = self.columns[_('Name')].column_indices[1]
return not model[_iter][torrent_name_col].lower().startswith(key.lower())
diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py
index d9e080a..4fdee4f 100644
--- a/deluge/ui/tracker_icons.py
+++ b/deluge/ui/tracker_icons.py
@@ -461,15 +461,12 @@ class TrackerIcons(Component):
# Requires Pillow(PIL) to resize.
if icon and Image:
filename = icon.get_filename()
- remove_old = False
with Image.open(filename) as img:
+ new_filename = os.path.splitext(filename)[0] + '.png'
if img.size > (16, 16):
- new_filename = filename.rpartition('.')[0] + '.png'
img = img.resize((16, 16), Image.Resampling.LANCZOS)
- img.save(new_filename)
- if new_filename != filename:
- remove_old = True
- if remove_old:
+ img.save(new_filename)
+ if new_filename != filename:
os.remove(filename)
icon = TrackerIcon(new_filename)
return icon
diff --git a/requirements-ci.txt b/requirements-ci.txt
index 0ebcd60..4a1a9c8 100644
--- a/requirements-ci.txt
+++ b/requirements-ci.txt
@@ -1,4 +1,2 @@
-r requirements.txt
-r requirements-tests.txt
-libtorrent==2.0.7
-pytest==7.4.2