diff options
author | Erik Johnston <erik@matrix.org> | 2019-12-05 17:58:25 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2019-12-05 17:58:25 +0000 |
commit | 8437e2383ed2dffacca5395851023eeacb33d7ba (patch) | |
tree | b16b2cac8d11126b64731cfdef918352269f96b1 /tests/unittest.py | |
parent | Merge pull request #6483 from matrix-org/erikj/port_rest_v2 (diff) | |
download | synapse-8437e2383ed2dffacca5395851023eeacb33d7ba.tar.xz |
Port SyncHandler to async/await
Diffstat (limited to 'tests/unittest.py')
-rw-r--r-- | tests/unittest.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/unittest.py b/tests/unittest.py index 295573bc46..a1bdd963e6 100644 --- a/tests/unittest.py +++ b/tests/unittest.py @@ -18,6 +18,7 @@ import gc import hashlib import hmac +import inspect import logging import time @@ -25,7 +26,7 @@ from mock import Mock from canonicaljson import json -from twisted.internet.defer import Deferred, succeed +from twisted.internet.defer import Deferred, ensureDeferred, succeed from twisted.python.threadpool import ThreadPool from twisted.trial import unittest @@ -415,6 +416,8 @@ 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 self.pump(by=by) @@ -424,6 +427,8 @@ class HomeserverTestCase(TestCase): """ 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 self.pump() |