diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2022-04-01 16:10:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-01 16:10:31 +0100 |
commit | 33ebee47e4e96a2b6fdf72091769e59034dc550f (patch) | |
tree | e77cad2918fd13cd14100e8e7f2e0856900a69ca /tests/unittest.py | |
parent | Default to `private` room visibility rather than `public` when a client does ... (diff) | |
download | synapse-33ebee47e4e96a2b6fdf72091769e59034dc550f.tar.xz |
Remove redundant `get_success` calls in test code (#12346)
There are a bunch of places we call get_success on an immediate value, which is unnecessary. Let's rip them out, and remove the redundant functionality in get_success and friends.
Diffstat (limited to 'tests/unittest.py')
-rw-r--r-- | tests/unittest.py | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/tests/unittest.py b/tests/unittest.py index cbe215ee83..5b19065c71 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -16,7 +16,6 @@ import gc import hashlib import hmac -import inspect import json import logging import secrets @@ -519,33 +518,23 @@ class HomeserverTestCase(TestCase): self.reactor.pump([by] * 100) def get_success(self, d, by=0.0): - if inspect.isawaitable(d): - d = ensureDeferred(d) - if not isinstance(d, Deferred): - return d + deferred: Deferred[TV] = ensureDeferred(d) self.pump(by=by) - return self.successResultOf(d) + return self.successResultOf(deferred) def get_failure(self, d, exc): """ Run a Deferred and get a Failure from it. The failure must be of the type `exc`. """ - if inspect.isawaitable(d): - d = ensureDeferred(d) - if not isinstance(d, Deferred): - return d + deferred: Deferred[Any] = ensureDeferred(d) self.pump() - return self.failureResultOf(d, exc) + return self.failureResultOf(deferred, exc) def get_success_or_raise(self, d, by=0.0): """Drive deferred to completion and return result or raise exception on failure. """ - - if inspect.isawaitable(d): - deferred = ensureDeferred(d) - if not isinstance(deferred, Deferred): - return d + deferred: Deferred[TV] = ensureDeferred(d) results: list = [] deferred.addBoth(results.append) |