summaryrefslogtreecommitdiffstats
path: root/deluge/ui
diff options
context:
space:
mode:
authorChase Sterling <chase.sterling@gmail.com>2022-01-29 14:59:19 -0500
committerCalum Lind <calumlind+deluge@gmail.com>2022-02-03 22:29:32 +0000
commitece31cf3cfb2ae277194f82bf35b45ea848f69c4 (patch)
tree1ddc8752488f079a372796e7f8aef5a3c3e6c537 /deluge/ui
parent0fbb3882f2d86751b25adf0e01eabcdd1316048a (diff)
downloaddeluge-ece31cf3cfb2ae277194f82bf35b45ea848f69c4.tar.gz
deluge-ece31cf3cfb2ae277194f82bf35b45ea848f69c4.tar.bz2
deluge-ece31cf3cfb2ae277194f82bf35b45ea848f69c4.zip
[Tests] Transition tests to pure pytest
Convert all the twisted.trial tests to pytest_twisted. Also move off of unittest.TestCase as well. Seems there were several tests which weren't actually testing what they should, and also some code that wasn't doing what the broken test said it should. Goals: Remove twisted.trial tests Move to pytest fixtures, rather than many classess and subclasses with setup and teardown functions Move away from self.assertX to assert style tests FIx broken tests Going forward I think these should be the goals when adding/modifying tests: * Don't use BaseTest or set_up tear_down methods any more. Fixtures should be used either in the test module/class, or make/improve the ones available in conftest.py * For sure don't use unittest or twisted.trial, they mess up the pytest stuff. * Prefer pytest_twisted.ensureDeferred with an async function over inlineCallbacks. - I think the async function syntax is nicer, and it helps catch silly mistakes, e.g. await None is invalid, but yield None isn't, so if some function returns an unexpected thing we try to await on, it will be caught earlier. (I struggled debugging a test for quite a while, then caught it immediately when switching to the new syntax) - Once the maybe_coroutine PR goes in, using the async syntax can also improve tracebacks when debugging tests. Things that should probably be cleaned up going forward: * Remove BaseTestCase * Remove the subclasses like DaemonBase in favor of new fixtures. * I think there are some other utility subclasses that could be removed too * Perhaps use parameterization in the ui_entry tests, rather that the weird combination of subclasses and the set_var fixture I mixed in. * Convert some of the callback stuff to pytest_twisted.ensureDeferred tests, just for nicer readability Details relating to pytest fixtures conftest.py in root dir: * https://github.com/pytest-dev/pytest/issues/5822#issuecomment-697331920 * https://docs.pytest.org/en/latest/deprecations.html#pytest-plugins-in-non-top-level-conftest-files Closes: https://github.com/deluge-torrent/deluge/pull/354
Diffstat (limited to 'deluge/ui')
-rw-r--r--deluge/ui/client.py2
-rw-r--r--deluge/ui/console/__init__.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/deluge/ui/client.py b/deluge/ui/client.py
index fc3509cf4..6b657d5ca 100644
--- a/deluge/ui/client.py
+++ b/deluge/ui/client.py
@@ -612,7 +612,7 @@ class Client:
d.addErrback(on_authenticate_fail)
return d
- d.addCallback(on_connected)
+ d.addCallbacks(on_connected)
d.addErrback(on_connect_fail)
if not skip_authentication:
d.addCallback(authenticate, username, password)
diff --git a/deluge/ui/console/__init__.py b/deluge/ui/console/__init__.py
index 5152980fc..7da04a6de 100644
--- a/deluge/ui/console/__init__.py
+++ b/deluge/ui/console/__init__.py
@@ -13,4 +13,4 @@ UI_PATH = __path__[0]
def start():
- Console().start()
+ return Console().start()