Use mock from the stdlib. (#9772)

This commit is contained in:
Patrick Cloke 2021-04-09 13:44:38 -04:00 committed by GitHub
parent f946450184
commit 0b3112123d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
82 changed files with 86 additions and 126 deletions

1
changelog.d/9772.misc Normal file
View file

@ -0,0 +1 @@
Use mock from the standard library instead of a separate package.

View file

@ -23,11 +23,10 @@ ignore=W503,W504,E203,E731,E501,B007
[isort] [isort]
line_length = 88 line_length = 88
sections=FUTURE,STDLIB,COMPAT,THIRDPARTY,TWISTED,FIRSTPARTY,TESTS,LOCALFOLDER sections=FUTURE,STDLIB,THIRDPARTY,TWISTED,FIRSTPARTY,TESTS,LOCALFOLDER
default_section=THIRDPARTY default_section=THIRDPARTY
known_first_party = synapse known_first_party = synapse
known_tests=tests known_tests=tests
known_compat = mock
known_twisted=twisted,OpenSSL known_twisted=twisted,OpenSSL
multi_line_output=3 multi_line_output=3
include_trailing_comma=true include_trailing_comma=true

View file

@ -110,7 +110,7 @@ CONDITIONAL_REQUIREMENTS["mypy"] = ["mypy==0.812", "mypy-zope==0.2.13"]
# Tests assume that all optional dependencies are installed. # Tests assume that all optional dependencies are installed.
# #
# parameterized_class decorator was introduced in parameterized 0.7.0 # 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( setup(
name="matrix-synapse", name="matrix-synapse",

View file

@ -16,8 +16,7 @@
import logging import logging
import warnings import warnings
from io import StringIO from io import StringIO
from unittest.mock import Mock
from mock import Mock
from pyperf import perf_counter from pyperf import perf_counter

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
import pymacaroons import pymacaroons

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock, patch from unittest.mock import Mock, patch
from parameterized import parameterized from parameterized import parameterized

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import re import re
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import time import time
from unittest.mock import Mock
from mock import Mock
import attr import attr
import canonicaljson import canonicaljson

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import Dict, Iterable, List, Optional, Set, Tuple, Union from typing import Dict, Iterable, List, Optional, Set, Tuple, Union
from unittest.mock import Mock
from mock import Mock
import attr import attr
@ -314,7 +313,8 @@ class PresenceRouterTestCase(FederatingHomeserverTestCase):
self.hs.get_federation_transport_client().send_transaction.call_args_list self.hs.get_federation_transport_client().send_transaction.call_args_list
) )
for call in calls: 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 # Get the sent EDUs in this transaction
edus = federation_transaction.get_dict()["edus"] edus = federation_transaction.get_dict()["edus"]

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.api.errors import Codes, SynapseError from synapse.api.errors import Codes, SynapseError
from synapse.rest import admin from synapse.rest import admin

View file

@ -1,6 +1,5 @@
from typing import List, Tuple from typing import List, Tuple
from unittest.mock import Mock
from mock import Mock
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes
from synapse.events import EventBase from synapse.events import EventBase

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import Optional from typing import Optional
from unittest.mock import Mock
from mock import Mock
from signedjson import key, sign from signedjson import key, sign
from signedjson.types import BaseKey, SigningKey from signedjson.types import BaseKey, SigningKey

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
from collections import Counter from collections import Counter
from unittest.mock import Mock
from mock import Mock
import synapse.api.errors import synapse.api.errors
import synapse.handlers.admin import synapse.handlers.admin

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
import pymacaroons import pymacaroons

View file

@ -11,7 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.handlers.cas_handler import CasResponse from synapse.handlers.cas_handler import CasResponse

View file

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
import synapse import synapse
import synapse.api.errors import synapse.api.errors

View file

@ -14,7 +14,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from signedjson import key as key, sign as sign from signedjson import key as key, sign as sign

View file

@ -16,8 +16,7 @@
# limitations under the License. # limitations under the License.
import copy import copy
from unittest import mock
import mock
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError

View file

@ -14,10 +14,9 @@
# limitations under the License. # limitations under the License.
import json import json
import os import os
from unittest.mock import ANY, Mock, patch
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
from mock import ANY, Mock, patch
import pymacaroons import pymacaroons
from synapse.handlers.sso import MappingException from synapse.handlers.sso import MappingException

View file

@ -16,8 +16,7 @@
"""Tests for the password_auth_provider interface""" """Tests for the password_auth_provider interface"""
from typing import Any, Type, Union from typing import Any, Type, Union
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
from mock import Mock, call from unittest.mock import Mock, call
from signedjson.key import generate_signing_key from signedjson.key import generate_signing_key

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
import synapse.types import synapse.types
from synapse.api.errors import AuthError, SynapseError from synapse.api.errors import AuthError, SynapseError

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.api.auth import Auth from synapse.api.auth import Auth
from synapse.api.constants import UserTypes from synapse.api.constants import UserTypes

View file

@ -13,8 +13,7 @@
# limitations under the License. # limitations under the License.
from typing import Optional from typing import Optional
from unittest.mock import Mock
from mock import Mock
import attr import attr

View file

@ -16,8 +16,7 @@
import json import json
from typing import Dict from typing import Dict
from unittest.mock import ANY, Mock, call
from mock import ANY, Mock, call
from twisted.internet import defer from twisted.internet import defer
from twisted.web.resource import Resource from twisted.web.resource import Resource

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import logging import logging
from typing import Optional from typing import Optional
from unittest.mock import Mock
from mock import Mock
import treq import treq
from netaddr import IPSet from netaddr import IPSet

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.defer import Deferred from twisted.internet.defer import Deferred

View file

@ -13,8 +13,7 @@
# limitations under the License. # limitations under the License.
from io import BytesIO from io import BytesIO
from unittest.mock import Mock
from mock import Mock
from netaddr import IPSet from netaddr import IPSet

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from netaddr import IPSet from netaddr import IPSet
from parameterized import parameterized from parameterized import parameterized

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import json import json
from io import BytesIO from io import BytesIO
from unittest.mock import Mock
from mock import Mock
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError
from synapse.http.servlet import ( from synapse.http.servlet import (

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from netaddr import IPSet from netaddr import IPSet

View file

@ -15,8 +15,7 @@
import json import json
import logging import logging
from io import BytesIO, StringIO from io import BytesIO, StringIO
from unittest.mock import Mock, patch
from mock import Mock, patch
from twisted.web.server import Request from twisted.web.server import Request

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.api.constants import EduTypes from synapse.api.constants import EduTypes
from synapse.events import EventBase from synapse.events import EventBase
@ -358,7 +358,8 @@ class ModuleApiTestCase(FederatingHomeserverTestCase):
self.hs.get_federation_transport_client().send_transaction.call_args_list self.hs.get_federation_transport_client().send_transaction.call_args_list
) )
for call in calls: 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 # Get the sent EDUs in this transaction
edus = federation_transaction.get_dict()["edus"] edus = federation_transaction.get_dict()["edus"]

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet.defer import Deferred from twisted.internet.defer import Deferred

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from tests.replication._base import BaseStreamTestCase from tests.replication._base import BaseStreamTestCase

View file

@ -15,7 +15,7 @@
# type: ignore # type: ignore
from mock import Mock from unittest.mock import Mock
from synapse.replication.tcp.streams._base import ReceiptsStream from synapse.replication.tcp.streams._base import ReceiptsStream

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.handlers.typing import RoomMember from synapse.handlers.typing import RoomMember
from synapse.replication.tcp.streams import TypingStream from synapse.replication.tcp.streams import TypingStream

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import mock from unittest import mock
from synapse.app.generic_worker import GenericWorkerServer from synapse.app.generic_worker import GenericWorkerServer
from synapse.replication.tcp.commands import FederationAckCommand from synapse.replication.tcp.commands import FederationAckCommand

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging import logging
from unittest.mock import Mock
from mock import Mock
from synapse.api.constants import EventTypes, Membership from synapse.api.constants import EventTypes, Membership
from synapse.events.builder import EventBuilderFactory from synapse.events.builder import EventBuilderFactory

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging import logging
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import logging import logging
from unittest.mock import patch
from mock import patch
from synapse.api.room_versions import RoomVersion from synapse.api.room_versions import RoomVersion
from synapse.rest import admin from synapse.rest import admin

View file

@ -17,8 +17,7 @@ import json
import os import os
import urllib.parse import urllib.parse
from binascii import unhexlify from binascii import unhexlify
from unittest.mock import Mock
from mock import Mock
from twisted.internet.defer import Deferred from twisted.internet.defer import Deferred

View file

@ -16,8 +16,7 @@
import json import json
import urllib.parse import urllib.parse
from typing import List, Optional from typing import List, Optional
from unittest.mock import Mock
from mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.api.constants import EventTypes, Membership from synapse.api.constants import EventTypes, Membership

View file

@ -19,8 +19,7 @@ import json
import urllib.parse import urllib.parse
from binascii import unhexlify from binascii import unhexlify
from typing import List, Optional from typing import List, Optional
from unittest.mock import Mock
from mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.api.constants import UserTypes from synapse.api.constants import UserTypes

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes
from synapse.rest import admin from synapse.rest import admin

View file

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock, patch from unittest.mock import Mock, patch
import synapse.rest.admin import synapse.rest.admin
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import threading import threading
from typing import Dict from typing import Dict
from unittest.mock import Mock
from mock import Mock
from synapse.events import EventBase from synapse.events import EventBase
from synapse.module_api import ModuleApi from synapse.module_api import ModuleApi

View file

@ -1,4 +1,4 @@
from mock import Mock, call from unittest.mock import Mock, call
from twisted.internet import defer, reactor from twisted.internet import defer, reactor

View file

@ -15,7 +15,7 @@
""" Tests REST events for /events paths.""" """ Tests REST events for /events paths."""
from mock import Mock from unittest.mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.rest.client.v1 import events, login, room from synapse.rest.client.v1 import events, login, room

View file

@ -16,10 +16,9 @@
import time import time
import urllib.parse import urllib.parse
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
from unittest.mock import Mock
from urllib.parse import urlencode from urllib.parse import urlencode
from mock import Mock
import pymacaroons import pymacaroons
from twisted.web.resource import Resource from twisted.web.resource import Resource

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -20,10 +20,9 @@
import json import json
from typing import Iterable from typing import Iterable
from unittest.mock import Mock
from urllib import parse as urlparse from urllib import parse as urlparse
from mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.api.constants import EventContentFields, EventTypes, Membership from synapse.api.constants import EventContentFields, EventTypes, Membership
from synapse.handlers.pagination import PurgeStatus from synapse.handlers.pagination import PurgeStatus

View file

@ -16,7 +16,7 @@
"""Tests REST events for /rooms paths.""" """Tests REST events for /rooms paths."""
from mock import Mock from unittest.mock import Mock
from synapse.rest.client.v1 import room from synapse.rest.client.v1 import room
from synapse.types import UserID from synapse.types import UserID

View file

@ -21,8 +21,7 @@ import re
import time import time
import urllib.parse import urllib.parse
from typing import Any, Dict, Mapping, MutableMapping, Optional from typing import Any, Dict, Mapping, MutableMapping, Optional
from unittest.mock import patch
from mock import patch
import attr import attr

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import urllib.parse import urllib.parse
from io import BytesIO, StringIO from io import BytesIO, StringIO
from unittest.mock import Mock
from mock import Mock
import signedjson.key import signedjson.key
from canonicaljson import encode_canonical_json from canonicaljson import encode_canonical_json

View file

@ -18,10 +18,9 @@ import tempfile
from binascii import unhexlify from binascii import unhexlify
from io import BytesIO from io import BytesIO
from typing import Optional from typing import Optional
from unittest.mock import Mock
from urllib import parse from urllib import parse
from mock import Mock
import attr import attr
from parameterized import parameterized_class from parameterized import parameterized_class
from PIL import Image as Image from PIL import Image as Image

View file

@ -15,8 +15,7 @@
import json import json
import os import os
import re import re
from unittest.mock import patch
from mock import patch
from twisted.internet._resolver import HostResolution from twisted.internet._resolver import HostResolution
from twisted.internet.address import IPv4Address, IPv6Address from twisted.internet.address import IPv4Address, IPv6Address

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse._scripts.register_new_matrix_user import request_registration from synapse._scripts.register_new_matrix_user import request_registration

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -15,8 +15,7 @@
import json import json
import os import os
import tempfile import tempfile
from unittest.mock import Mock
from mock import Mock
import yaml import yaml

View file

@ -1,4 +1,4 @@
from mock import Mock from unittest.mock import Mock
from synapse.storage.background_updates import BackgroundUpdater from synapse.storage.background_updates import BackgroundUpdater

View file

@ -15,8 +15,7 @@
from collections import OrderedDict from collections import OrderedDict
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -14,9 +14,7 @@
# limitations under the License. # limitations under the License.
import os.path import os.path
from unittest.mock import patch from unittest.mock import Mock, patch
from mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
import synapse.rest.admin import synapse.rest.admin
from synapse.http.site import XForwardedForRequest from synapse.http.site import XForwardedForRequest

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from tests.unittest import HomeserverTestCase from tests.unittest import HomeserverTestCase

View file

@ -12,7 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock, patch from unittest.mock import Mock, patch
from synapse.util.distributor import Distributor from synapse.util.distributor import Distributor

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from twisted.internet.defer import succeed from twisted.internet.defer import succeed

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import resource import resource
from unittest import mock
import mock
from synapse.app.phone_stats_home import phone_stats_home from synapse.app.phone_stats_home import phone_stats_home

View file

@ -13,8 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from typing import List, Optional from typing import List, Optional
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer

View file

@ -13,8 +13,7 @@
# limitations under the License. # limitations under the License.
import json import json
from unittest.mock import Mock
from mock import Mock
from twisted.test.proto_helpers import MemoryReactorClock from twisted.test.proto_helpers import MemoryReactorClock

View file

@ -21,8 +21,7 @@ import sys
import warnings import warnings
from asyncio import Future from asyncio import Future
from typing import Any, Awaitable, Callable, TypeVar from typing import Any, Awaitable, Callable, TypeVar
from unittest.mock import Mock
from mock import Mock
import attr import attr

View file

@ -14,8 +14,7 @@
# limitations under the License. # limitations under the License.
import logging import logging
from typing import Optional from typing import Optional
from unittest.mock import Mock
from mock import Mock
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.defer import succeed from twisted.internet.defer import succeed

View file

@ -21,8 +21,7 @@ import inspect
import logging import logging
import time import time
from typing import Callable, Dict, Iterable, Optional, Tuple, Type, TypeVar, Union from typing import Callable, Dict, Iterable, Optional, Tuple, Type, TypeVar, Union
from unittest.mock import Mock, patch
from mock import Mock, patch
from canonicaljson import json from canonicaljson import json

View file

@ -15,8 +15,7 @@
# limitations under the License. # limitations under the License.
import logging import logging
from typing import Set from typing import Set
from unittest import mock
import mock
from twisted.internet import defer, reactor from twisted.internet import defer, reactor

View file

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.util.caches.ttlcache import TTLCache from synapse.util.caches.ttlcache import TTLCache

View file

@ -16,8 +16,7 @@
import threading import threading
from io import StringIO from io import StringIO
from unittest.mock import NonCallableMock
from mock import NonCallableMock
from twisted.internet import defer, reactor from twisted.internet import defer, reactor

View file

@ -14,7 +14,7 @@
# limitations under the License. # limitations under the License.
from mock import Mock from unittest.mock import Mock
from synapse.util.caches.lrucache import LruCache from synapse.util.caches.lrucache import LruCache
from synapse.util.caches.treecache import TreeCache from synapse.util.caches.treecache import TreeCache

View file

@ -21,10 +21,9 @@ import time
import uuid import uuid
import warnings import warnings
from typing import Type from typing import Type
from unittest.mock import Mock, patch
from urllib import parse as urlparse from urllib import parse as urlparse
from mock import Mock, patch
from twisted.internet import defer from twisted.internet import defer
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes