diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2023-02-28 13:25:17 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2023-02-28 15:21:18 +0100 |
commit | 9ce8afe507b7fb0414196b99e5eaef4552a46e96 (patch) | |
tree | c573a4b4fcbf9972ac4684e5e765c898d94e6733 | |
parent | [Tests] Remove unneeded component teardown (diff) | |
download | deluge-9ce8afe507b7fb0414196b99e5eaef4552a46e96.tar.xz deluge-9ce8afe507b7fb0414196b99e5eaef4552a46e96.zip |
[Tests] Fix component warning in Plugin tests
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
-rw-r--r-- | deluge/conftest.py | 2 | ||||
-rw-r--r-- | deluge/plugins/Stats/deluge_stats/tests/test_stats.py | 5 | ||||
-rw-r--r-- | deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py | 12 | ||||
-rw-r--r-- | deluge/plugins/pluginbase.py | 5 | ||||
-rw-r--r-- | pyproject.toml | 4 |
5 files changed, 13 insertions, 15 deletions
diff --git a/deluge/conftest.py b/deluge/conftest.py index 55c50a42d..51acc6a12 100644 --- a/deluge/conftest.py +++ b/deluge/conftest.py @@ -137,7 +137,7 @@ def common_fixture(config_dir, request, monkeypatch, listen_port): @pytest_twisted.async_yield_fixture(scope='function') -async def component(request): +async def component(): """Verify component registry is clean, and clean up after test.""" if len(_component._ComponentRegistry.components) != 0: warnings.warn( diff --git a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py index 9c66ee107..4aefc509d 100644 --- a/deluge/plugins/Stats/deluge_stats/tests/test_stats.py +++ b/deluge/plugins/Stats/deluge_stats/tests/test_stats.py @@ -7,7 +7,6 @@ import pytest import pytest_twisted from twisted.internet import defer -import deluge.component as component from deluge.common import fsize, fspeed from deluge.ui.client import client @@ -21,17 +20,15 @@ def print_totals(totals): print('down:', fsize(totals['total_download'] - totals['total_payload_download'])) -@pytest.mark.usefixtures('component') class TestStatsPlugin: @pytest_twisted.async_yield_fixture(autouse=True) - async def set_up(self): + async def set_up(self, component): defer.setDebugging(True) client.start_standalone() client.core.enable_plugin('Stats') await component.start() yield client.stop_standalone() - await component.shutdown() @defer.inlineCallbacks def test_client_totals(self): diff --git a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py index 1badedca0..413d25925 100644 --- a/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py +++ b/deluge/plugins/WebUi/deluge_webui/tests/test_plugin_webui.py @@ -8,7 +8,6 @@ import pytest import pytest_twisted -import deluge.component as component from deluge.core.core import Core from deluge.core.rpcserver import RPCServer from deluge.tests import common @@ -16,10 +15,9 @@ from deluge.tests import common common.disable_new_release_check() -@pytest.mark.usefixtures('component') class TestWebUIPlugin: @pytest_twisted.async_yield_fixture(autouse=True) - async def set_up(self, request): + async def set_up(self, request, component): self = request.instance self.rpcserver = RPCServer(listen=False) self.core = Core() @@ -27,11 +25,9 @@ class TestWebUIPlugin: yield - def on_shutdown(result): - del self.rpcserver - del self.core - - await component.shutdown().addCallback(on_shutdown) + await component.shutdown() + del self.rpcserver + del self.core def test_enable_webui(self): if 'WebUi' not in self.core.get_available_plugins(): diff --git a/deluge/plugins/pluginbase.py b/deluge/plugins/pluginbase.py index 58162feab..8d5515690 100644 --- a/deluge/plugins/pluginbase.py +++ b/deluge/plugins/pluginbase.py @@ -34,7 +34,10 @@ class CorePluginBase(PluginBase): log.debug('CorePlugin initialized..') def __del__(self): - component.get('RPCServer').deregister_object(self) + try: + component.get('RPCServer').deregister_object(self) + except KeyError: + log.debug('RPCServer already deregistered') def enable(self): super().enable() diff --git a/pyproject.toml b/pyproject.toml index 500b285e4..0449619d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,8 @@ markers = [ ] filterwarnings = [ "ignore::DeprecationWarning:gi", - "ignore::DeprecationWarning:twisted.internet.gireactor:43", + "ignore::DeprecationWarning:twisted.internet.gireactor", "ignore:twisted.web.resource.*:DeprecationWarning", + "ignore:Using readBody.*:DeprecationWarning", + "ignore:resume_data is deprecated.*:DeprecationWarning:deluge.core.alertmanager", ] |