summaryrefslogtreecommitdiff
path: root/tests/unittest.py
diff options
context:
space:
mode:
authorAndrej Shadura <andrewsh@debian.org>2020-02-22 11:02:03 +0300
committerAndrej Shadura <andrewsh@debian.org>2020-02-22 11:02:03 +0300
commit4b3a9670d149fa9e5ccd8427af01c91cb657fbf7 (patch)
tree8f5e13c25ee10726c9351dea0dfcf2bcf6657a82 /tests/unittest.py
parentcd4f94423a6b511d504e0c792d6644973f505d71 (diff)
New upstream version 1.11.0
Diffstat (limited to 'tests/unittest.py')
-rw-r--r--tests/unittest.py28
1 files changed, 19 insertions, 9 deletions
diff --git a/tests/unittest.py b/tests/unittest.py
index 98bf27d3..8816a4d1 100644
--- a/tests/unittest.py
+++ b/tests/unittest.py
@@ -21,6 +21,7 @@ import hmac
import inspect
import logging
import time
+from typing import Optional, Tuple, Type, TypeVar, Union
from mock import Mock
@@ -42,7 +43,13 @@ from synapse.server import HomeServer
from synapse.types import Requester, UserID, create_requester
from synapse.util.ratelimitutils import FederationRateLimiter
-from tests.server import get_clock, make_request, render, setup_test_homeserver
+from tests.server import (
+ FakeChannel,
+ get_clock,
+ make_request,
+ render,
+ setup_test_homeserver,
+)
from tests.test_utils.logging_setup import setup_logging
from tests.utils import default_config, setupdb
@@ -71,6 +78,9 @@ def around(target):
return _around
+T = TypeVar("T")
+
+
class TestCase(unittest.TestCase):
"""A subclass of twisted.trial's TestCase which looks for 'loglevel'
attributes on both itself and its individual test methods, to override the
@@ -334,14 +344,14 @@ class HomeserverTestCase(TestCase):
def make_request(
self,
- method,
- path,
- content=b"",
- access_token=None,
- request=SynapseRequest,
- shorthand=True,
- federation_auth_origin=None,
- ):
+ method: Union[bytes, str],
+ path: Union[bytes, str],
+ content: Union[bytes, dict] = b"",
+ access_token: Optional[str] = None,
+ request: Type[T] = SynapseRequest,
+ shorthand: bool = True,
+ federation_auth_origin: str = None,
+ ) -> Tuple[T, FakeChannel]:
"""
Create a SynapseRequest at the path using the method and containing the
given content.