diff options
author | Erik Johnston <erik@matrix.org> | 2019-12-09 11:32:44 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-09 11:32:44 +0000 |
commit | a9b393340fb9e4bf227f5ef0ca3de708748a617c (patch) | |
tree | b80d67d8eaf89bb1e993cf159643229b4672541a /tests/unittest.py | |
parent | Merge pull request #6469 from matrix-org/erikj/make_database_class (diff) | |
parent | Fixup functions to consistently return deferreds (diff) | |
download | synapse-a9b393340fb9e4bf227f5ef0ca3de708748a617c.tar.xz |
Merge pull request #6484 from matrix-org/erikj/port_sync_handler
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 68d245ec9f..b30b7d1718 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 @@ -417,6 +418,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) @@ -426,6 +429,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() |