Since all of our async tests should be run with twisted, it's
annoying to have to decorate them with pytest_twisted.ensureDeferred.
Forgetting to do this will cause the test to pass without actually
running. This changes the behavior to detect all coroutine function
tests and mark them to be run by pytest_twisted the same way the
decorator does.
Closes: https://github.com/deluge-torrent/deluge/pull/414
Modified test functions to be async.
Used pytest_twisted_ensuredeferred_for_class decorator to avoid needed
ensureDeferred for each test within the class. There might be a way to
do this with fixtures so likely to be improvements for use in all test
classes.
Used Mock in component subclass for simpler tracking of event method calls
Daemon logfile were being stored in dir where tests were started from
which cluttered up local dev env.
Entry point logfiles are stored in config dir since getting tmp_path in
set_up was a bit too tricky.
With key shortcuts set in the glade files it is not easy to change
the shortcuts on macOS.
Add AccelPaths to each MenuItem to allow adding or modifying accelerator
in codes. Uses the recommended format `<Deluge-MainWindow>/MenuName`
Update menubar code to use new functionality, taking advantage of
accelerator_parse to specify accelerators as strings instead of Gdk
flags.
A future idea would be to use `Gtk.AccelMap.load` to have shortcuts
loaded from user config.
Co-authored-by: Gregorio Litenstein <g.litenstein@gmail.com>
Simplify the code for setting the base path, both via headers and
config. Replaced putchild since it is not recommended for dynamic
paths and overriding getChildWithDefault provides a proper solution.
This also fixes recursive base path problem with previous code where
appending base paths to URL would still return Deluge web e.g.
http://localhost:8112/deluge/deluge/deluge
Removed getChild override by consolidating empty path conditional to
getChildWithDefault. This simplifies and combines the returning of
TopLevel resource for root path or base path.
Added workaround for test logfile error with forwardslash in filename
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
The component fixture was warning about existing registered components since
the standalone client was setup before the componentregistry test was performed.
The problem is due to fixture ordering with the setup fixture running
first since it was marked with autouse followed by component fixture.
* Fixed warning by moving component fixture as a dependency of the set_up fixture
* Cleaned up unneeded code
* Added try..except to catch CorePluginBase KeyError deregistering
RPCServer since component fixture already removed it.
* Ignore test-specific Twisted readBody warnings
The input is being passed as `str` instead of `int`, so added a
conversion only if the string is indeed a decimal number.
In addition, closing the add host popup after adding it.
Closes: https://dev.deluge-torrent.org/ticket/3538
When in console, and adding a new host with an invalid port number, the
console starts printing many exceptions regarding the value.
Therefor, we will make sure that the port value is between 0 and 65535.
Improve readability
Move imports available on Windows out of try..except.
For future reference in Python 3.11 termios now has window size methods
but the added complexity of handling older Python versions is not worth
it.
https://docs.python.org/3/library/termios.html#termios.tcgetwinsize
When adding a new torrent, there is a problem changing the path on
Windows machines, due to the difference between the way the files are
being read from the torrent and how we handle them in addtorrentdialog.
This effects both changing and showing the files in the UI.
Now, all path seperator is being considered and converted to slash '/'.
Closes: https://dev.deluge-torrent.org/ticket/3541
Closes: https://github.com/deluge-torrent/deluge/pull/395
Update to latest version of isort to fix install error:
RuntimeError: The Poetry configuration is invalid:
- [extras.pipfile_deprecated_finder.2] 'pip-shims<=0.3.4' does not match '^[a-zA-Z-_.0-9]+$'
Also update the Linting CI to latest version
GitHub pytest runner stalling with the following error:
[Errno 2] No such file or directory: '/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages/deluge/plugins'
This is related to the editable install of Deluge via pip
pip install -e .
and the custom resource_filename in deluge.common is the source of the
problem where a DistInfoDistribution returns a different path to
EggInfoDistribution.
Working egg-info install
>>> pkg_resources.get_distribution('Deluge')
deluge 2.1.1.dev8 (/home/user/deluge)
>>> type(pkg_resources.get_distribution('Deluge'))
<class 'pkg_resources.EggInfoDistribution'>
>>> pkg_resources.resource_filename('deluge', 'plugins')
'/home/user/deluge/deluge/plugins'
This can identified by the `deluge.egg-info` directory in source
directory.
Broken dist-info install
>>> pkg_resources.get_distribution('Deluge')
deluge 2.1.1.dev8 (/opt/hostedtoolcache/Python/3.10.8/x64/lib/python3.10/site-packages)
>>> type(pkg_resources.get_distribution('Deluge'))
<class 'pkg_resources.DistInfoDistribution'>
>>> pkg_resources.resource_filename('deluge', 'plugins')
'/home/user/deluge/deluge/plugins'
This can be worked around by setting an env var that enables legacy mode
but long-term need to replace the custom resource_filename and replace
usage of pkg_resources.
https://setuptools.pypa.io/en/latest/userguide/development_mode.html#legacy-behaviorhttps://setuptools.pypa.io/en/latest/pkg_resources.html
The enchant package was renamed for version 2 to enchant-2 and original
enchant package removed in Ubuntu 22.04 so docs workflow failed
Fixed by using latest package and specifying ubuntu version to avoid
unexpected failures in future.
Magnets with trackers specified with tr.x param were not being unquoted
so unusable raw tracker string was being set.
Fixed by unquoting tracker and adding test
See-also: https://dev.deluge-torrent.org/ticket/2716
The changes to remove deprecated lt methods didn't account for magnet
trackers so magnets are missing trackers when added.
Previously the addition of trackers was handled by libtorrent when a url
was passed in add_torrent_params. The url parameter is deprecated so
instead we need to add both the info_hash and trackers.
Trac: https://dev.deluge-torrent.org/ticket/3530
A recent dependency change caused the tests running on GitHub Actions
under Python 3.10.5 on Windows to fail when starting pytest run:
...
INTERNALERROR> File "<frozen importlib._bootstrap>", line 123, in acquire
INTERNALERROR> KeyError: xxxx
The cause seems to have been a newer version of chardet package released
recently.
* Fixed by pinning chardet to v4
* Also pin Windows version to 2019 to match packaging workflow
See-also: https://github.com/deluge-torrent/deluge/actions/runs/2578427588
Issue: https://github.com/chardet/chardet/issues/265
Fix rendering issues in ReadTheDocs by specifying latest version of
sphinx-rtd-theme. Normally not an issue to install this latest
dependency from doc/requirement.txt but RTD installs in the env an older
version (<0.5) before running requirements file install
thus sphinx-rtd-theme is not upgraded unless a version is specified.
See-also: https://github.com/readthedocs/sphinx_rtd_theme/issues/1115