summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2022-05-23 13:23:26 +0200
committerGitHub <noreply@github.com>2022-05-23 11:23:26 +0000
commit444588c5fc5e4fd0f3796d389fe5f062acc55286 (patch)
tree9fc7c743e6f3b19361f61035a0e6c381e782e947 /tests
parentFix Complement `TestCanRegisterAdmin` with workers, by adding Complement's sh... (diff)
downloadsynapse-444588c5fc5e4fd0f3796d389fe5f062acc55286.tar.xz
Add some type hints to tests files (#12833)
Co-authored-by: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/http/test_servlet.py14
-rw-r--r--tests/http/test_site.py2
-rw-r--r--tests/scripts/test_new_matrix_user.py13
-rw-r--r--tests/storage/test_base.py2
-rw-r--r--tests/storage/test_roommember.py2
5 files changed, 18 insertions, 15 deletions
diff --git a/tests/http/test_servlet.py b/tests/http/test_servlet.py

index ad521525cf..b3655d7b44 100644 --- a/tests/http/test_servlet.py +++ b/tests/http/test_servlet.py
@@ -49,19 +49,21 @@ class TestServletUtils(unittest.TestCase): """Basic tests for parse_json_value_from_request.""" # Test round-tripping. obj = {"foo": 1} - result = parse_json_value_from_request(make_request(obj)) - self.assertEqual(result, obj) + result1 = parse_json_value_from_request(make_request(obj)) + self.assertEqual(result1, obj) # Results don't have to be objects. - result = parse_json_value_from_request(make_request(b'["foo"]')) - self.assertEqual(result, ["foo"]) + result2 = parse_json_value_from_request(make_request(b'["foo"]')) + self.assertEqual(result2, ["foo"]) # Test empty. with self.assertRaises(SynapseError): parse_json_value_from_request(make_request(b"")) - result = parse_json_value_from_request(make_request(b""), allow_empty_body=True) - self.assertIsNone(result) + result3 = parse_json_value_from_request( + make_request(b""), allow_empty_body=True + ) + self.assertIsNone(result3) # Invalid UTF-8. with self.assertRaises(SynapseError): diff --git a/tests/http/test_site.py b/tests/http/test_site.py
index 8c13b4f693..b2dbf76d33 100644 --- a/tests/http/test_site.py +++ b/tests/http/test_site.py
@@ -36,7 +36,7 @@ class SynapseRequestTestCase(HomeserverTestCase): # as a control case, first send a regular request. # complete the connection and wire it up to a fake transport - client_address = IPv6Address("TCP", "::1", "2345") + client_address = IPv6Address("TCP", "::1", 2345) protocol = factory.buildProtocol(client_address) transport = StringTransport() protocol.makeConnection(transport) diff --git a/tests/scripts/test_new_matrix_user.py b/tests/scripts/test_new_matrix_user.py
index 19a145eeb6..22f99c6ab1 100644 --- a/tests/scripts/test_new_matrix_user.py +++ b/tests/scripts/test_new_matrix_user.py
@@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from typing import List from unittest.mock import Mock, patch from synapse._scripts.register_new_matrix_user import request_registration @@ -49,8 +50,8 @@ class RegisterTestCase(TestCase): requests.post = post # The fake stdout will be written here - out = [] - err_code = [] + out: List[str] = [] + err_code: List[int] = [] with patch("synapse._scripts.register_new_matrix_user.requests", requests): request_registration( @@ -85,8 +86,8 @@ class RegisterTestCase(TestCase): requests.get = get # The fake stdout will be written here - out = [] - err_code = [] + out: List[str] = [] + err_code: List[int] = [] with patch("synapse._scripts.register_new_matrix_user.requests", requests): request_registration( @@ -137,8 +138,8 @@ class RegisterTestCase(TestCase): requests.post = post # The fake stdout will be written here - out = [] - err_code = [] + out: List[str] = [] + err_code: List[int] = [] with patch("synapse._scripts.register_new_matrix_user.requests", requests): request_registration( diff --git a/tests/storage/test_base.py b/tests/storage/test_base.py
index a8ffb52c05..cce8e75c74 100644 --- a/tests/storage/test_base.py +++ b/tests/storage/test_base.py
@@ -60,7 +60,7 @@ class SQLBaseStoreTestCase(unittest.TestCase): db = DatabasePool(Mock(), Mock(config=sqlite_config), fake_engine) db._db_pool = self.db_pool - self.datastore = SQLBaseStore(db, None, hs) + self.datastore = SQLBaseStore(db, None, hs) # type: ignore[arg-type] @defer.inlineCallbacks def test_insert_1col(self): diff --git a/tests/storage/test_roommember.py b/tests/storage/test_roommember.py
index a2a9c05f24..1218786d79 100644 --- a/tests/storage/test_roommember.py +++ b/tests/storage/test_roommember.py
@@ -34,7 +34,7 @@ class RoomMemberStoreTestCase(unittest.HomeserverTestCase): room.register_servlets, ] - def prepare(self, reactor: MemoryReactor, clock: Clock, hs: TestHomeServer) -> None: + def prepare(self, reactor: MemoryReactor, clock: Clock, hs: TestHomeServer) -> None: # type: ignore[override] # We can't test the RoomMemberStore on its own without the other event # storage logic