Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use mock from the stdlib. #7709

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/7709.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use mock from the standard library instead of a separate package.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ sections=FUTURE,STDLIB,COMPAT,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
Expand Down
2 changes: 1 addition & 1 deletion synapse/python_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"oidc": ["authlib>=0.14.0"],
"systemd": ["systemd-python>=231"],
"url_preview": ["lxml>=3.5.0"],
"test": ["mock>=2.0", "parameterized"],
"test": ["parameterized"],
"sentry": ["sentry-sdk>=0.7.2"],
"opentracing": ["jaeger-client>=4.0.0", "opentracing>=2.2.0"],
"jwt": ["pyjwt>=1.6.4"],
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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 jsonschema

Expand Down
2 changes: 1 addition & 1 deletion tests/app/test_openid_listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/appservice/test_appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/appservice/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/crypto/test_keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 canonicaljson
import signedjson.key
Expand Down
2 changes: 1 addition & 1 deletion tests/federation/test_complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/federation/test_federation_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/handlers/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.


from mock import Mock
from unittest.mock import Mock

from twisted.internet import defer

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_e2e_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import mock
from unittest import mock

import signedjson.key as key
import signedjson.sign as sign
Expand Down
3 changes: 1 addition & 2 deletions tests/handlers/test_e2e_room_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
# limitations under the License.

import copy

import mock
from unittest import mock

from twisted.internet import defer

Expand Down
3 changes: 1 addition & 2 deletions tests/handlers/test_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
# limitations under the License.

import json
from unittest.mock import Mock, patch
from urllib.parse import parse_qs, urlparse

from mock import Mock, patch

import attr
import pymacaroons

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.


from mock import Mock
from unittest.mock import Mock

from twisted.internet import defer

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/handlers/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@


import json

from mock import ANY, Mock, call
from unittest.mock import ANY, Mock, call

from twisted.internet import defer

Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/test_user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/http/federation/test_matrix_federation_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

import treq
from service_identity import VerificationError
Expand Down
2 changes: 1 addition & 1 deletion tests/http/federation/test_srv_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/http/test_fedclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/push/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 Deferred

Expand Down
2 changes: 1 addition & 1 deletion tests/replication/slave/storage/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/replication/tcp/streams/test_receipts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# type: ignore

from mock import Mock
from unittest.mock import Mock

from synapse.replication.tcp.streams._base import ReceiptsStream

Expand Down
2 changes: 1 addition & 1 deletion tests/replication/tcp/streams/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/replication/test_federation_ack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/rest/admin/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import os
import urllib.parse
from binascii import unhexlify

from mock import Mock
from unittest.mock import Mock

from twisted.internet.defer import Deferred

Expand Down
3 changes: 1 addition & 2 deletions tests/rest/admin/test_room.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.errors import Codes
Expand Down
3 changes: 1 addition & 2 deletions tests/rest/admin/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import hmac
import json
import urllib.parse

from mock import Mock
from unittest.mock import Mock

import synapse.rest.admin
from synapse.api.constants import UserTypes
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/test_retention.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/test_transactions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mock import Mock, call
from unittest.mock import Mock, call

from twisted.internet import defer, reactor

Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/rest/client/v1/test_login.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json
import time
import urllib.parse

from mock import Mock
from unittest.mock import Mock

import jwt

Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions tests/rest/client/v1/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

"""Tests REST events for /profile paths."""
import json

from mock import Mock
from unittest.mock import Mock

from twisted.internet import defer

Expand Down
3 changes: 1 addition & 2 deletions tests/rest/client/v1/test_rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
"""Tests REST events for /rooms paths."""

import json
from unittest.mock import Mock
from urllib import parse as urlparse

from mock import Mock

from twisted.internet import defer

import synapse.rest.admin
Expand Down
2 changes: 1 addition & 1 deletion tests/rest/client/v1/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

"""Tests REST events for /rooms paths."""

from mock import Mock
from unittest.mock import Mock

from twisted.internet import defer

Expand Down
3 changes: 1 addition & 2 deletions tests/rest/key/v2/test_remote_key_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading