diff --git a/changelog.d/9772.misc b/changelog.d/9772.misc
new file mode 100644
index 0000000000000000000000000000000000000000..ec7d94cc257658b440ba0f521e7297955fe43905
--- /dev/null
+++ b/changelog.d/9772.misc
@@ -0,0 +1 @@
+Use mock from the standard library instead of a separate package.
diff --git a/setup.cfg b/setup.cfg
index 5fdb51ac7397805856ee03fd45678c07ed475d1a..33601b71d58c1a4aedd58fe55eccc9ea1b9b77ff 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -23,11 +23,10 @@ ignore=W503,W504,E203,E731,E501,B007
 
 [isort]
 line_length = 88
-sections=FUTURE,STDLIB,COMPAT,THIRDPARTY,TWISTED,FIRSTPARTY,TESTS,LOCALFOLDER
+sections=FUTURE,STDLIB,THIRDPARTY,TWISTED,FIRSTPARTY,TESTS,LOCALFOLDER
 default_section=THIRDPARTY
 known_first_party = synapse
 known_tests=tests
-known_compat = mock
 known_twisted=twisted,OpenSSL
 multi_line_output=3
 include_trailing_comma=true
diff --git a/setup.py b/setup.py
index 4e9e333c6089b55d063f5dac93a98b274e9a567e..2eb70d0bb321c8bfc215db97d103955c4c47f036 100755
--- a/setup.py
+++ b/setup.py
@@ -110,7 +110,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = ["mypy==0.812", "mypy-zope==0.2.13"]
 # Tests assume that all optional dependencies are installed.
 #
 # parameterized_class decorator was introduced in parameterized 0.7.0
-CONDITIONAL_REQUIREMENTS["test"] = ["mock>=2.0", "parameterized>=0.7.0"]
+CONDITIONAL_REQUIREMENTS["test"] = ["parameterized>=0.7.0"]
 
 setup(
     name="matrix-synapse",
diff --git a/synmark/suites/logging.py b/synmark/suites/logging.py
index c306891b27f452779080724a1a0d560281b17fe7..b3abc6b254b84c8eddef3afd7369fa54f24698f4 100644
--- a/synmark/suites/logging.py
+++ b/synmark/suites/logging.py
@@ -16,8 +16,7 @@
 import logging
 import warnings
 from io import StringIO
-
-from mock import Mock
+from unittest.mock import Mock
 
 from pyperf import perf_counter
 
diff --git a/tests/api/test_auth.py b/tests/api/test_auth.py
index 34f72ae795c74a0c4e6dc2568a940b2e760f65bb..28d77f0ca2381d654547f5bb1f27502126d8973e 100644
--- a/tests/api/test_auth.py
+++ b/tests/api/test_auth.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 import pymacaroons
 
diff --git a/tests/app/test_openid_listener.py b/tests/app/test_openid_listener.py
index 467033e201be091074334ae6ba0fa89f91f48088..33a37fe35eac0f2e5262b594aa90ef1c532a5c0c 100644
--- a/tests/app/test_openid_listener.py
+++ b/tests/app/test_openid_listener.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 
 from parameterized import parameterized
 
diff --git a/tests/appservice/test_appservice.py b/tests/appservice/test_appservice.py
index 0bffeb11508199a926cef6a396a6fadff99ec12a..03a7440eec5f260f46ebbc30df721ab7eca42001 100644
--- a/tests/appservice/test_appservice.py
+++ b/tests/appservice/test_appservice.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import re
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/appservice/test_scheduler.py b/tests/appservice/test_scheduler.py
index 97f8cad0ddd4ac8388d78f397f350f90f8622108..3c27d797fb378816dc5e302bff399329e43f4959 100644
--- a/tests/appservice/test_scheduler.py
+++ b/tests/appservice/test_scheduler.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/crypto/test_keyring.py b/tests/crypto/test_keyring.py
index 946482b7e706a4e3a18d18f5ec1abbd908dbc6e4..a56063315be014ffc0a1f2bb9dee0f4516dec9a6 100644
--- a/tests/crypto/test_keyring.py
+++ b/tests/crypto/test_keyring.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import time
-
-from mock import Mock
+from unittest.mock import Mock
 
 import attr
 import canonicaljson
diff --git a/tests/events/test_presence_router.py b/tests/events/test_presence_router.py
index c6e547f11c4d2511c35d6127c388534c49e5cab0..c996ecc221a15fd126ac92c0105e793864b476a7 100644
--- a/tests/events/test_presence_router.py
+++ b/tests/events/test_presence_router.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 from typing import Dict, Iterable, List, Optional, Set, Tuple, Union
-
-from mock import Mock
+from unittest.mock import Mock
 
 import attr
 
@@ -314,7 +313,8 @@ class PresenceRouterTestCase(FederatingHomeserverTestCase):
             self.hs.get_federation_transport_client().send_transaction.call_args_list
         )
         for call in calls:
-            federation_transaction = call.args[0]  # type: Transaction
+            call_args = call[0]
+            federation_transaction = call_args[0]  # type: Transaction
 
             # Get the sent EDUs in this transaction
             edus = federation_transaction.get_dict()["edus"]
diff --git a/tests/federation/test_complexity.py b/tests/federation/test_complexity.py
index 8186b8ca013cc2c12673663ade46e83fe85b1c5b..701fa8379fff896b52bc525e558ffc2065e34346 100644
--- a/tests/federation/test_complexity.py
+++ b/tests/federation/test_complexity.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.errors import Codes, SynapseError
 from synapse.rest import admin
diff --git a/tests/federation/test_federation_catch_up.py b/tests/federation/test_federation_catch_up.py
index 95eac6a5a34c53b47c2bd8d24530d082e8fc61c9..802c5ad299d3b8ad81ab09a1c67bcb1becad4044 100644
--- a/tests/federation/test_federation_catch_up.py
+++ b/tests/federation/test_federation_catch_up.py
@@ -1,6 +1,5 @@
 from typing import List, Tuple
-
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.constants import EventTypes
 from synapse.events import EventBase
diff --git a/tests/federation/test_federation_sender.py b/tests/federation/test_federation_sender.py
index ecc3faa57218ea9138aff277c0f94a0866d12fea..deb12433cf4f44ff86096999e12458e6a9d69bad 100644
--- a/tests/federation/test_federation_sender.py
+++ b/tests/federation/test_federation_sender.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 from typing import Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 from signedjson import key, sign
 from signedjson.types import BaseKey, SigningKey
diff --git a/tests/handlers/test_admin.py b/tests/handlers/test_admin.py
index a01fdd083981d7c0804f67ae6d110124a12db7e8..32669ae9ced61e467a3311f898e5a9a85397bdfd 100644
--- a/tests/handlers/test_admin.py
+++ b/tests/handlers/test_admin.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 
 from collections import Counter
-
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.api.errors
 import synapse.handlers.admin
diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py
index d5d3fdd99a9ef32fb6fc7fef0fb9402eeb5df905..6e325b24cee13d4e297e9a17512975e0ba2557ac 100644
--- a/tests/handlers/test_appservice.py
+++ b/tests/handlers/test_appservice.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/handlers/test_auth.py b/tests/handlers/test_auth.py
index c9f889b5117d9222f9e9f5c029a60a250442afb4..321c5ba045fb218a845ca4fd76cad553aa1ecda6 100644
--- a/tests/handlers/test_auth.py
+++ b/tests/handlers/test_auth.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 import pymacaroons
 
diff --git a/tests/handlers/test_cas.py b/tests/handlers/test_cas.py
index 7975af243c7c6b510db66821d2dfccd013e23d67..0444b26798893c29669f7f7ca410d5969daf256b 100644
--- a/tests/handlers/test_cas.py
+++ b/tests/handlers/test_cas.py
@@ -11,7 +11,7 @@
 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.handlers.cas_handler import CasResponse
 
diff --git a/tests/handlers/test_directory.py b/tests/handlers/test_directory.py
index 863d8737b2f8d766d8c5fb03281ac627f626583c..6ae9d4f8656f0474141e0dce88185518d99e90d6 100644
--- a/tests/handlers/test_directory.py
+++ b/tests/handlers/test_directory.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse
 import synapse.api.errors
diff --git a/tests/handlers/test_e2e_keys.py b/tests/handlers/test_e2e_keys.py
index 5e86c5e56bf4e929c16c1ab3f51d88aa1fa69339..6915ac0205f086dadbc12e414f870702b1f0a2bd 100644
--- a/tests/handlers/test_e2e_keys.py
+++ b/tests/handlers/test_e2e_keys.py
@@ -14,7 +14,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-import mock
+from unittest import mock
 
 from signedjson import key as key, sign as sign
 
diff --git a/tests/handlers/test_e2e_room_keys.py b/tests/handlers/test_e2e_room_keys.py
index d7498aa51a804db170d2b93bd5876e30bdce95d7..07893302ecbe3b861a5dbeff4c44d5f29a93d7d9 100644
--- a/tests/handlers/test_e2e_room_keys.py
+++ b/tests/handlers/test_e2e_room_keys.py
@@ -16,8 +16,7 @@
 # limitations under the License.
 
 import copy
-
-import mock
+from unittest import mock
 
 from synapse.api.errors import SynapseError
 
diff --git a/tests/handlers/test_oidc.py b/tests/handlers/test_oidc.py
index c7796fb837bc99b74d02ea946e0dde7012c7da96..8702ee70e0de0881c6c06b04894d52814e70e91f 100644
--- a/tests/handlers/test_oidc.py
+++ b/tests/handlers/test_oidc.py
@@ -14,10 +14,9 @@
 # limitations under the License.
 import json
 import os
+from unittest.mock import ANY, Mock, patch
 from urllib.parse import parse_qs, urlparse
 
-from mock import ANY, Mock, patch
-
 import pymacaroons
 
 from synapse.handlers.sso import MappingException
diff --git a/tests/handlers/test_password_providers.py b/tests/handlers/test_password_providers.py
index a98a65ae67e42c99018b64a949618d992a6590c3..e28e4159eba5e9d11e07487476df9945c0622c01 100644
--- a/tests/handlers/test_password_providers.py
+++ b/tests/handlers/test_password_providers.py
@@ -16,8 +16,7 @@
 """Tests for the password_auth_provider interface"""
 
 from typing import Any, Type, Union
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py
index 77330f59a987ce2e5a03f64e9a160f00fa8bd436..9f16cc65fc2e75651c44bef10147b5d87b291c7b 100644
--- a/tests/handlers/test_presence.py
+++ b/tests/handlers/test_presence.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 
-from mock import Mock, call
+from unittest.mock import Mock, call
 
 from signedjson.key import generate_signing_key
 
diff --git a/tests/handlers/test_profile.py b/tests/handlers/test_profile.py
index 75c6a4e21cb5c69ce04dc36f5f5a4358eddba754..d8b1bcac8b49c36df44a0b4ca5762215a5151306 100644
--- a/tests/handlers/test_profile.py
+++ b/tests/handlers/test_profile.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.types
 from synapse.api.errors import AuthError, SynapseError
diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py
index 94b69035945b7edd22be01798e2ba7d221f89394..69279a5ce9fd276868b3ddcb19abbacaf2af95ce 100644
--- a/tests/handlers/test_register.py
+++ b/tests/handlers/test_register.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.auth import Auth
 from synapse.api.constants import UserTypes
diff --git a/tests/handlers/test_saml.py b/tests/handlers/test_saml.py
index 30efd43b4060edc61dc2fa98d34e4ff6d73e0c8d..8cfc184fefc90638549e495e1d8c4d11d766d26f 100644
--- a/tests/handlers/test_saml.py
+++ b/tests/handlers/test_saml.py
@@ -13,8 +13,7 @@
 #  limitations under the License.
 
 from typing import Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 import attr
 
diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index 24e71381965aebd9ed21e5ae8f2ecea08f636304..9fa231a37a958a3b6963218d7c21fa50701e80fd 100644
--- a/tests/handlers/test_typing.py
+++ b/tests/handlers/test_typing.py
@@ -16,8 +16,7 @@
 
 import json
 from typing import Dict
-
-from mock import ANY, Mock, call
+from unittest.mock import ANY, Mock, call
 
 from twisted.internet import defer
 from twisted.web.resource import Resource
diff --git a/tests/handlers/test_user_directory.py b/tests/handlers/test_user_directory.py
index 98b2f5b3837738188c9a6835e6bcb93a27ea9405..c68cb830afcded209417844690b1a0d1def53a0c 100644
--- a/tests/handlers/test_user_directory.py
+++ b/tests/handlers/test_user_directory.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/http/federation/test_matrix_federation_agent.py b/tests/http/federation/test_matrix_federation_agent.py
index 73e12ea6c3ca6e068c6547d4e3254204c2fd6729..ae9d4504a8c01f6d14a14698637ffbde1fa1fb3d 100644
--- a/tests/http/federation/test_matrix_federation_agent.py
+++ b/tests/http/federation/test_matrix_federation_agent.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 import logging
 from typing import Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 import treq
 from netaddr import IPSet
diff --git a/tests/http/federation/test_srv_resolver.py b/tests/http/federation/test_srv_resolver.py
index fee2985d350e5a6aef72c5636990781f809ca2c6..466ce722d9ce1b3e38314e01ef981f112bfcf913 100644
--- a/tests/http/federation/test_srv_resolver.py
+++ b/tests/http/federation/test_srv_resolver.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 from twisted.internet.defer import Deferred
diff --git a/tests/http/test_client.py b/tests/http/test_client.py
index 0ce181a51e9475c5972d9dd201b1f2afb5eba93c..7e2f2a01cc074bcbb2dbf57377d3867a9863d553 100644
--- a/tests/http/test_client.py
+++ b/tests/http/test_client.py
@@ -13,8 +13,7 @@
 #  limitations under the License.
 
 from io import BytesIO
-
-from mock import Mock
+from unittest.mock import Mock
 
 from netaddr import IPSet
 
diff --git a/tests/http/test_fedclient.py b/tests/http/test_fedclient.py
index 9c52c8fdca1495d396751f488b35062f42a86bc8..21c1297171af71abf17a0d8469a46772a1788c9e 100644
--- a/tests/http/test_fedclient.py
+++ b/tests/http/test_fedclient.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from netaddr import IPSet
 from parameterized import parameterized
diff --git a/tests/http/test_servlet.py b/tests/http/test_servlet.py
index 45089158ceb6c790b1a3daa727bb5a08dfac7990..f979c96f7cdc777269673fda5acd74c36a2187c8 100644
--- a/tests/http/test_servlet.py
+++ b/tests/http/test_servlet.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 import json
 from io import BytesIO
-
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.errors import SynapseError
 from synapse.http.servlet import (
diff --git a/tests/http/test_simple_client.py b/tests/http/test_simple_client.py
index a1cf0862d4fe293b65dbd3e2e3dcdca01e48190b..cc4cae320d36a003535c7b3338c4670fd0c5d0c3 100644
--- a/tests/http/test_simple_client.py
+++ b/tests/http/test_simple_client.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from netaddr import IPSet
 
diff --git a/tests/logging/test_terse_json.py b/tests/logging/test_terse_json.py
index bfe0d11c9364f45909fcf6cba733243ae4f1f29a..215fd8b0f9e3297f5e323b906332037925af36b6 100644
--- a/tests/logging/test_terse_json.py
+++ b/tests/logging/test_terse_json.py
@@ -15,8 +15,7 @@
 import json
 import logging
 from io import BytesIO, StringIO
-
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 
 from twisted.web.server import Request
 
diff --git a/tests/module_api/test_api.py b/tests/module_api/test_api.py
index 1d1fceeecf441eb730e876ce995f413ff31cdccc..349f93560e9de27a92eab4f9e421cb873e845d83 100644
--- a/tests/module_api/test_api.py
+++ b/tests/module_api/test_api.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.constants import EduTypes
 from synapse.events import EventBase
@@ -358,7 +358,8 @@ class ModuleApiTestCase(FederatingHomeserverTestCase):
             self.hs.get_federation_transport_client().send_transaction.call_args_list
         )
         for call in calls:
-            federation_transaction = call.args[0]  # type: Transaction
+            call_args = call[0]
+            federation_transaction = call_args[0]  # type: Transaction
 
             # Get the sent EDUs in this transaction
             edus = federation_transaction.get_dict()["edus"]
diff --git a/tests/push/test_http.py b/tests/push/test_http.py
index 60f0820cffbddb0883fcd2ca6258f3289fa52717..4074ade87a145ea8b597d7384499f4d1dfb1bc78 100644
--- a/tests/push/test_http.py
+++ b/tests/push/test_http.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet.defer import Deferred
 
diff --git a/tests/replication/slave/storage/_base.py b/tests/replication/slave/storage/_base.py
index 56497b8476eecbde19f3b641cedede97b2af2846..83e89383f64ff3d66762db2536a825f9f4d6f062 100644
--- a/tests/replication/slave/storage/_base.py
+++ b/tests/replication/slave/storage/_base.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from tests.replication._base import BaseStreamTestCase
 
diff --git a/tests/replication/tcp/streams/test_receipts.py b/tests/replication/tcp/streams/test_receipts.py
index 56b062ecc1d671a5d8077ca4b814b13d135847ec..7d848e41ffed9dd2ef19ef6dca4d1610db1e6509 100644
--- a/tests/replication/tcp/streams/test_receipts.py
+++ b/tests/replication/tcp/streams/test_receipts.py
@@ -15,7 +15,7 @@
 
 # type: ignore
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.replication.tcp.streams._base import ReceiptsStream
 
diff --git a/tests/replication/tcp/streams/test_typing.py b/tests/replication/tcp/streams/test_typing.py
index ca49d4dd3af266bc09d85feb08df81561f3468e0..4a0b34226443e1817a1480efa09073fb889e70a6 100644
--- a/tests/replication/tcp/streams/test_typing.py
+++ b/tests/replication/tcp/streams/test_typing.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.handlers.typing import RoomMember
 from synapse.replication.tcp.streams import TypingStream
diff --git a/tests/replication/test_federation_ack.py b/tests/replication/test_federation_ack.py
index 0d9e3bb11dba9dab9dab973e842b78148684fdbc..44ad5eec57eff323b886364823ae1d884af9ef62 100644
--- a/tests/replication/test_federation_ack.py
+++ b/tests/replication/test_federation_ack.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import mock
+from unittest import mock
 
 from synapse.app.generic_worker import GenericWorkerServer
 from synapse.replication.tcp.commands import FederationAckCommand
diff --git a/tests/replication/test_federation_sender_shard.py b/tests/replication/test_federation_sender_shard.py
index 2f2d117858f095c0ba8c9ec9cc3c56959850573e..8ca595c3eeabf125a25da6ade4d5e67adb2f5cf3 100644
--- a/tests/replication/test_federation_sender_shard.py
+++ b/tests/replication/test_federation_sender_shard.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import logging
-
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.constants import EventTypes, Membership
 from synapse.events.builder import EventBuilderFactory
diff --git a/tests/replication/test_pusher_shard.py b/tests/replication/test_pusher_shard.py
index ab2988a6ba4732e4b3a15bedcbf8e6a68fd167c5..1f12bde1aa47241c21f7066375a3faddbf6227db 100644
--- a/tests/replication/test_pusher_shard.py
+++ b/tests/replication/test_pusher_shard.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import logging
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/replication/test_sharded_event_persister.py b/tests/replication/test_sharded_event_persister.py
index c9b773fbd2156e8e212dba066652b482ea990514..6c2e1674cb21b51bd669bfe73f25915c931ab909 100644
--- a/tests/replication/test_sharded_event_persister.py
+++ b/tests/replication/test_sharded_event_persister.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import logging
-
-from mock import patch
+from unittest.mock import patch
 
 from synapse.api.room_versions import RoomVersion
 from synapse.rest import admin
diff --git a/tests/rest/admin/test_admin.py b/tests/rest/admin/test_admin.py
index 057e27372e1ef87d0bab3cd82467d457e52bcca5..4abcbe3f553a353ea1b17b5bef7b8949009c60dc 100644
--- a/tests/rest/admin/test_admin.py
+++ b/tests/rest/admin/test_admin.py
@@ -17,8 +17,7 @@ import json
 import os
 import urllib.parse
 from binascii import unhexlify
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet.defer import Deferred
 
diff --git a/tests/rest/admin/test_room.py b/tests/rest/admin/test_room.py
index b55160b70afac05d01a123f01a146a65b5eb2592..85f77c0a659e3c918438511721389eb0786b5fce 100644
--- a/tests/rest/admin/test_room.py
+++ b/tests/rest/admin/test_room.py
@@ -16,8 +16,7 @@
 import json
 import urllib.parse
 from typing import List, Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.rest.admin
 from synapse.api.constants import EventTypes, Membership
diff --git a/tests/rest/admin/test_user.py b/tests/rest/admin/test_user.py
index 0c9ec133c2ccb9d395af6bba3a6fd3db5a7c2c9e..e47fd3ded83d04d491ce1a2ac59cda9ab63b33be 100644
--- a/tests/rest/admin/test_user.py
+++ b/tests/rest/admin/test_user.py
@@ -19,8 +19,7 @@ import json
 import urllib.parse
 from binascii import unhexlify
 from typing import List, Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.rest.admin
 from synapse.api.constants import UserTypes
diff --git a/tests/rest/client/test_retention.py b/tests/rest/client/test_retention.py
index aee99bb6a0aa49198c725d7056e2e29859e2d8e6..f892a712289457fb1c81abc19f45154ac1c77c10 100644
--- a/tests/rest/client/test_retention.py
+++ b/tests/rest/client/test_retention.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.api.constants import EventTypes
 from synapse.rest import admin
diff --git a/tests/rest/client/test_shadow_banned.py b/tests/rest/client/test_shadow_banned.py
index d2cce44032fa71b7b24b67d460a2fca3cc51df17..288ee128886be7ce11114a21cb78adb8e8eacded 100644
--- a/tests/rest/client/test_shadow_banned.py
+++ b/tests/rest/client/test_shadow_banned.py
@@ -12,7 +12,7 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.
 
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 
 import synapse.rest.admin
 from synapse.api.constants import EventTypes
diff --git a/tests/rest/client/test_third_party_rules.py b/tests/rest/client/test_third_party_rules.py
index bf39014277072a10abd88c3df4744b2bea58e2b8..a7ebe0c3e92188b327c21e49b1abc5ac90bf32ab 100644
--- a/tests/rest/client/test_third_party_rules.py
+++ b/tests/rest/client/test_third_party_rules.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 import threading
 from typing import Dict
-
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.events import EventBase
 from synapse.module_api import ModuleApi
diff --git a/tests/rest/client/test_transactions.py b/tests/rest/client/test_transactions.py
index 171632e195e2980ec5725fe3b52b99e2bd29290d..3b5747cb12b8d5f7cb948eae884454cad82574ad 100644
--- a/tests/rest/client/test_transactions.py
+++ b/tests/rest/client/test_transactions.py
@@ -1,4 +1,4 @@
-from mock import Mock, call
+from unittest.mock import Mock, call
 
 from twisted.internet import defer, reactor
 
diff --git a/tests/rest/client/v1/test_events.py b/tests/rest/client/v1/test_events.py
index 2ae896db1ec91170db7536aa35394455643f93d6..87a18d2cb94e548a435a736452a1526a69d38e9f 100644
--- a/tests/rest/client/v1/test_events.py
+++ b/tests/rest/client/v1/test_events.py
@@ -15,7 +15,7 @@
 
 """ Tests REST events for /events paths."""
 
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.rest.admin
 from synapse.rest.client.v1 import events, login, room
diff --git a/tests/rest/client/v1/test_login.py b/tests/rest/client/v1/test_login.py
index 988821b16f4d569ee27a8f29b4f03d89d34201cf..c7b79ab8a706889bb49a4adbd4f2f4217632274e 100644
--- a/tests/rest/client/v1/test_login.py
+++ b/tests/rest/client/v1/test_login.py
@@ -16,10 +16,9 @@
 import time
 import urllib.parse
 from typing import Any, Dict, List, Optional, Union
+from unittest.mock import Mock
 from urllib.parse import urlencode
 
-from mock import Mock
-
 import pymacaroons
 
 from twisted.web.resource import Resource
diff --git a/tests/rest/client/v1/test_presence.py b/tests/rest/client/v1/test_presence.py
index 94a5154834eceb85f093b13e80e9c78370da7518..c136827f7993d9b9c35e0fbdf3d8514f33f45d0b 100644
--- a/tests/rest/client/v1/test_presence.py
+++ b/tests/rest/client/v1/test_presence.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/rest/client/v1/test_rooms.py b/tests/rest/client/v1/test_rooms.py
index 715414a3107d67b20c10b02a689509798160e8f7..4df20c90fda823da097d7d60fb0b599ee6bf2833 100644
--- a/tests/rest/client/v1/test_rooms.py
+++ b/tests/rest/client/v1/test_rooms.py
@@ -20,10 +20,9 @@
 
 import json
 from typing import Iterable
+from unittest.mock import Mock
 from urllib import parse as urlparse
 
-from mock import Mock
-
 import synapse.rest.admin
 from synapse.api.constants import EventContentFields, EventTypes, Membership
 from synapse.handlers.pagination import PurgeStatus
diff --git a/tests/rest/client/v1/test_typing.py b/tests/rest/client/v1/test_typing.py
index 329dbd06def2b1edc23a38ba08c5c3ed1a5b8c04..0b8f5651211c60e7e9c47a088af2a142cd18c693 100644
--- a/tests/rest/client/v1/test_typing.py
+++ b/tests/rest/client/v1/test_typing.py
@@ -16,7 +16,7 @@
 
 """Tests REST events for /rooms paths."""
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.rest.client.v1 import room
 from synapse.types import UserID
diff --git a/tests/rest/client/v1/utils.py b/tests/rest/client/v1/utils.py
index 8a4dddae2b2a2635cd66f3bf65273bfe1f6e85a8..a6a292b20cfacb3f7f5dab1389dbb24ec0aa90b6 100644
--- a/tests/rest/client/v1/utils.py
+++ b/tests/rest/client/v1/utils.py
@@ -21,8 +21,7 @@ import re
 import time
 import urllib.parse
 from typing import Any, Dict, Mapping, MutableMapping, Optional
-
-from mock import patch
+from unittest.mock import patch
 
 import attr
 
diff --git a/tests/rest/key/v2/test_remote_key_resource.py b/tests/rest/key/v2/test_remote_key_resource.py
index 9d0d0ef41466db6a6d43b997f2c6755460b683f4..eb8687ce68c2a225e6fb2e9da309d5431ea96803 100644
--- a/tests/rest/key/v2/test_remote_key_resource.py
+++ b/tests/rest/key/v2/test_remote_key_resource.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 import urllib.parse
 from io import BytesIO, StringIO
-
-from mock import Mock
+from unittest.mock import Mock
 
 import signedjson.key
 from canonicaljson import encode_canonical_json
diff --git a/tests/rest/media/v1/test_media_storage.py b/tests/rest/media/v1/test_media_storage.py
index 9f77125fd445e6d871f13a7fb587621e7be475ed..375f0b797704e64a928b50131d2cc051183d9aae 100644
--- a/tests/rest/media/v1/test_media_storage.py
+++ b/tests/rest/media/v1/test_media_storage.py
@@ -18,10 +18,9 @@ import tempfile
 from binascii import unhexlify
 from io import BytesIO
 from typing import Optional
+from unittest.mock import Mock
 from urllib import parse
 
-from mock import Mock
-
 import attr
 from parameterized import parameterized_class
 from PIL import Image as Image
diff --git a/tests/rest/media/v1/test_url_preview.py b/tests/rest/media/v1/test_url_preview.py
index 6968502433913e9281ea23db97275c241ad89ff1..9067463e541f607aa2ddf7f8ec7a4b5e83317601 100644
--- a/tests/rest/media/v1/test_url_preview.py
+++ b/tests/rest/media/v1/test_url_preview.py
@@ -15,8 +15,7 @@
 import json
 import os
 import re
-
-from mock import patch
+from unittest.mock import patch
 
 from twisted.internet._resolver import HostResolution
 from twisted.internet.address import IPv4Address, IPv6Address
diff --git a/tests/scripts/test_new_matrix_user.py b/tests/scripts/test_new_matrix_user.py
index 6f56893f5e91b385c84906794f1d3e34dcc2514e..885b95a51f5ef9370a6fbded1e2f2e300e622e4f 100644
--- a/tests/scripts/test_new_matrix_user.py
+++ b/tests/scripts/test_new_matrix_user.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse._scripts.register_new_matrix_user import request_registration
 
diff --git a/tests/server_notices/test_resource_limits_server_notices.py b/tests/server_notices/test_resource_limits_server_notices.py
index d40d65b06a8bf91514479ba5adcebe8996c3a2d9..450b4ec710a2407ae8563a59087b7d3ac63b4666 100644
--- a/tests/server_notices/test_resource_limits_server_notices.py
+++ b/tests/server_notices/test_resource_limits_server_notices.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/storage/test_appservice.py b/tests/storage/test_appservice.py
index 1ce29af5fd9d75dec0c80f89f32da349de9ec9d1..e755a4db625de2a23d9b808edbc5a1b79586f8f5 100644
--- a/tests/storage/test_appservice.py
+++ b/tests/storage/test_appservice.py
@@ -15,8 +15,7 @@
 import json
 import os
 import tempfile
-
-from mock import Mock
+from unittest.mock import Mock
 
 import yaml
 
diff --git a/tests/storage/test_background_update.py b/tests/storage/test_background_update.py
index 1b4fae0bb555f3b95959e24efcaae669feeffa05..069db0edc43a3eea51f62b2944b4e49b92bf6928 100644
--- a/tests/storage/test_background_update.py
+++ b/tests/storage/test_background_update.py
@@ -1,4 +1,4 @@
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.storage.background_updates import BackgroundUpdater
 
diff --git a/tests/storage/test_base.py b/tests/storage/test_base.py
index eac7e4dcd2faa118e20e36381d8c5e8a54afff73..54e9e7f6fe9889756fe1a64b0422e81cf75c5032 100644
--- a/tests/storage/test_base.py
+++ b/tests/storage/test_base.py
@@ -15,8 +15,7 @@
 
 
 from collections import OrderedDict
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/storage/test_cleanup_extrems.py b/tests/storage/test_cleanup_extrems.py
index 7791138688805a445d0d99b28fbc2a517c5d95da..b02fb32ced739d17a1e1c816433c2a7462bab38c 100644
--- a/tests/storage/test_cleanup_extrems.py
+++ b/tests/storage/test_cleanup_extrems.py
@@ -14,9 +14,7 @@
 # limitations under the License.
 
 import os.path
-from unittest.mock import patch
-
-from mock import Mock
+from unittest.mock import Mock, patch
 
 import synapse.rest.admin
 from synapse.api.constants import EventTypes
diff --git a/tests/storage/test_client_ips.py b/tests/storage/test_client_ips.py
index a8a6ddc46610d4a12d473830c01e56352ccd2191..f7f75320ba9854dd84f539c4ce20a0915dd92aab 100644
--- a/tests/storage/test_client_ips.py
+++ b/tests/storage/test_client_ips.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 import synapse.rest.admin
 from synapse.http.site import XForwardedForRequest
diff --git a/tests/storage/test_event_push_actions.py b/tests/storage/test_event_push_actions.py
index 239f7c9faf97da1737f543feb091b22dc2258d73..0289942f88d26974070fdc1d4e61f67bf3b8557c 100644
--- a/tests/storage/test_event_push_actions.py
+++ b/tests/storage/test_event_push_actions.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from tests.unittest import HomeserverTestCase
 
diff --git a/tests/storage/test_monthly_active_users.py b/tests/storage/test_monthly_active_users.py
index 5858c7fcc4d267b88d618cd0a938d32ffa5d56d4..47556791f4f11568b927b159a7fc5ab4fb6b75dd 100644
--- a/tests/storage/test_monthly_active_users.py
+++ b/tests/storage/test_monthly_active_users.py
@@ -12,7 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/test_distributor.py b/tests/test_distributor.py
index b57f36e6ac262d41054ff335d4af406e9a93672f..6a6cf709f615318734b1bb0472a1ef32b260b821 100644
--- a/tests/test_distributor.py
+++ b/tests/test_distributor.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 
 from synapse.util.distributor import Distributor
 
diff --git a/tests/test_federation.py b/tests/test_federation.py
index fc9aab32d0636b92527e1aab5c76510e9dc49a2a..8928597d17dbb1741d397f12cd03c093b8c76675 100644
--- a/tests/test_federation.py
+++ b/tests/test_federation.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet.defer import succeed
 
diff --git a/tests/test_phone_home.py b/tests/test_phone_home.py
index e7aed092c2756dd0ec7604a7f2c41cf8b182a432..0f800a075bd4e1a540565e97ada55cd7cf4c7f83 100644
--- a/tests/test_phone_home.py
+++ b/tests/test_phone_home.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 
 import resource
-
-import mock
+from unittest import mock
 
 from synapse.app.phone_stats_home import phone_stats_home
 
diff --git a/tests/test_state.py b/tests/test_state.py
index 1d2019699df627e059a2f793b562d3ef8f17649d..83383d88724c89a19c3d861485347685ca532455 100644
--- a/tests/test_state.py
+++ b/tests/test_state.py
@@ -13,8 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 from typing import List, Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 
diff --git a/tests/test_terms_auth.py b/tests/test_terms_auth.py
index a743cdc3a937b654b9bdf172ad8ccd2118e84e96..0df480db9f17fadb2f61c2665facd572e875f880 100644
--- a/tests/test_terms_auth.py
+++ b/tests/test_terms_auth.py
@@ -13,8 +13,7 @@
 # limitations under the License.
 
 import json
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.test.proto_helpers import MemoryReactorClock
 
diff --git a/tests/test_utils/__init__.py b/tests/test_utils/__init__.py
index 43898d8142d9301be976e2bfca016c1fe1bfe5a5..b557ffd6925112e07a157e53a73bde8cbd307dfb 100644
--- a/tests/test_utils/__init__.py
+++ b/tests/test_utils/__init__.py
@@ -21,8 +21,7 @@ import sys
 import warnings
 from asyncio import Future
 from typing import Any, Awaitable, Callable, TypeVar
-
-from mock import Mock
+from unittest.mock import Mock
 
 import attr
 
diff --git a/tests/test_visibility.py b/tests/test_visibility.py
index 1b4dd47a8238d867294ffc76d294aac45781a500..e502ac197e84520001af676b772981d0223b3d1d 100644
--- a/tests/test_visibility.py
+++ b/tests/test_visibility.py
@@ -14,8 +14,7 @@
 # limitations under the License.
 import logging
 from typing import Optional
-
-from mock import Mock
+from unittest.mock import Mock
 
 from twisted.internet import defer
 from twisted.internet.defer import succeed
diff --git a/tests/unittest.py b/tests/unittest.py
index 57b6a395c79149be3cfc9e7954192180979a1e7d..92764434bdf8da7776773bafea0c400d19cf9c1b 100644
--- a/tests/unittest.py
+++ b/tests/unittest.py
@@ -21,8 +21,7 @@ import inspect
 import logging
 import time
 from typing import Callable, Dict, Iterable, Optional, Tuple, Type, TypeVar, Union
-
-from mock import Mock, patch
+from unittest.mock import Mock, patch
 
 from canonicaljson import json
 
diff --git a/tests/util/caches/test_descriptors.py b/tests/util/caches/test_descriptors.py
index e434e21aeee64997e2c63d1a2cf0096e97ec9ad7..2d1f9360e0b02abf576b0826d6cc4c116d1e10e4 100644
--- a/tests/util/caches/test_descriptors.py
+++ b/tests/util/caches/test_descriptors.py
@@ -15,8 +15,7 @@
 # limitations under the License.
 import logging
 from typing import Set
-
-import mock
+from unittest import mock
 
 from twisted.internet import defer, reactor
 
diff --git a/tests/util/caches/test_ttlcache.py b/tests/util/caches/test_ttlcache.py
index 816795c1365925fbeecd80afe7fff8484cdc8716..23018081e5a6480e5eb92d5d823e07489113b0e6 100644
--- a/tests/util/caches/test_ttlcache.py
+++ b/tests/util/caches/test_ttlcache.py
@@ -13,7 +13,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.util.caches.ttlcache import TTLCache
 
diff --git a/tests/util/test_file_consumer.py b/tests/util/test_file_consumer.py
index 2012263184f65f19ef16597fc2d1f2535844afee..d1372f6bc251e8395e3b53eea0ac6c67ef7dcfc0 100644
--- a/tests/util/test_file_consumer.py
+++ b/tests/util/test_file_consumer.py
@@ -16,8 +16,7 @@
 
 import threading
 from io import StringIO
-
-from mock import NonCallableMock
+from unittest.mock import NonCallableMock
 
 from twisted.internet import defer, reactor
 
diff --git a/tests/util/test_lrucache.py b/tests/util/test_lrucache.py
index a739a6aaaf8c5e137679759baf201ddb75299d34..ce4f1cc30a57a2f36c343c1f4533ab5295a8d931 100644
--- a/tests/util/test_lrucache.py
+++ b/tests/util/test_lrucache.py
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 
-from mock import Mock
+from unittest.mock import Mock
 
 from synapse.util.caches.lrucache import LruCache
 from synapse.util.caches.treecache import TreeCache
diff --git a/tests/utils.py b/tests/utils.py
index a141ee64966f71b761a51dd28a618a5f1fcaa661..2e34fad11c85b02a4a1fb02f41e7a24ac9e599d3 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -21,10 +21,9 @@ import time
 import uuid
 import warnings
 from typing import Type
+from unittest.mock import Mock, patch
 from urllib import parse as urlparse
 
-from mock import Mock, patch
-
 from twisted.internet import defer
 
 from synapse.api.constants import EventTypes