diff --git a/tests/client/client_tests.py b/tests/client/client_tests.py index e42ada12c..e73e726ab 100644 --- a/tests/client/client_tests.py +++ b/tests/client/client_tests.py @@ -39,8 +39,8 @@ import time import warnings from collections import defaultdict +from unittest import mock -import mock import pytest from pytest_localserver.http import ContentServer from pytest_localserver.https import DEFAULT_CERTIFICATE diff --git a/tests/client/exception_tests.py b/tests/client/exception_tests.py index 082835be3..056f23548 100644 --- a/tests/client/exception_tests.py +++ b/tests/client/exception_tests.py @@ -29,8 +29,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os +from unittest import mock -import mock import pytest import elasticapm diff --git a/tests/client/py3_exception_tests.py b/tests/client/py3_exception_tests.py index ad8bb10ca..e1ff057eb 100644 --- a/tests/client/py3_exception_tests.py +++ b/tests/client/py3_exception_tests.py @@ -38,7 +38,7 @@ # # -import mock +from unittest import mock from elasticapm.conf.constants import ERROR diff --git a/tests/config/central_config_tests.py b/tests/config/central_config_tests.py index 568cf180a..d3aaf4fe7 100644 --- a/tests/config/central_config_tests.py +++ b/tests/config/central_config_tests.py @@ -28,7 +28,8 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import mock +from unittest import mock + import pytest diff --git a/tests/config/tests.py b/tests/config/tests.py index 284f5694a..ba07d7795 100644 --- a/tests/config/tests.py +++ b/tests/config/tests.py @@ -35,8 +35,8 @@ import platform import stat from datetime import timedelta +from unittest import mock -import mock import pytest import elasticapm.conf diff --git a/tests/contrib/asyncio/aiohttp_web_tests.py b/tests/contrib/asyncio/aiohttp_web_tests.py index 929a8e1a7..4a63d8714 100644 --- a/tests/contrib/asyncio/aiohttp_web_tests.py +++ b/tests/contrib/asyncio/aiohttp_web_tests.py @@ -32,7 +32,8 @@ aiohttp = pytest.importorskip("aiohttp") # isort:skip -import mock +from unittest import mock + from multidict import MultiDict import elasticapm diff --git a/tests/contrib/asyncio/starlette_tests.py b/tests/contrib/asyncio/starlette_tests.py index fe80ea89b..602603273 100644 --- a/tests/contrib/asyncio/starlette_tests.py +++ b/tests/contrib/asyncio/starlette_tests.py @@ -35,8 +35,8 @@ starlette = pytest.importorskip("starlette") # isort:skip import os +from unittest import mock -import mock import urllib3 import wrapt from starlette.applications import Starlette diff --git a/tests/contrib/asyncio/tornado/tornado_tests.py b/tests/contrib/asyncio/tornado/tornado_tests.py index 499a28550..32a1efe75 100644 --- a/tests/contrib/asyncio/tornado/tornado_tests.py +++ b/tests/contrib/asyncio/tornado/tornado_tests.py @@ -33,8 +33,8 @@ tornado = pytest.importorskip("tornado") # isort:skip import os +from unittest import mock -import mock from wrapt import BoundFunctionWrapper import elasticapm diff --git a/tests/contrib/celery/flask_tests.py b/tests/contrib/celery/flask_tests.py index 29dd61fdb..cb7c53ed5 100644 --- a/tests/contrib/celery/flask_tests.py +++ b/tests/contrib/celery/flask_tests.py @@ -33,7 +33,7 @@ flask = pytest.importorskip("flask") # isort:skip celery = pytest.importorskip("celery") # isort:skip -import mock +from unittest import mock from elasticapm.conf.constants import ERROR, TRANSACTION diff --git a/tests/contrib/django/django_tests.py b/tests/contrib/django/django_tests.py index b9d16772a..8d01e1813 100644 --- a/tests/contrib/django/django_tests.py +++ b/tests/contrib/django/django_tests.py @@ -41,8 +41,8 @@ import logging import os from copy import deepcopy +from unittest import mock -import mock from django.conf import settings from django.contrib.auth.models import User from django.contrib.redirects.models import Redirect diff --git a/tests/contrib/django/wrapper_tests.py b/tests/contrib/django/wrapper_tests.py index 4c3f186fc..6464f17b7 100644 --- a/tests/contrib/django/wrapper_tests.py +++ b/tests/contrib/django/wrapper_tests.py @@ -32,7 +32,7 @@ # Installing an app is not reversible, so using this instrumentation "for real" would # pollute the Django instance used by pytest. -import mock +from unittest import mock from elasticapm.instrumentation.packages.django import DjangoAutoInstrumentation diff --git a/tests/contrib/flask/flask_tests.py b/tests/contrib/flask/flask_tests.py index 776e74dd9..6dff7c18d 100644 --- a/tests/contrib/flask/flask_tests.py +++ b/tests/contrib/flask/flask_tests.py @@ -35,9 +35,9 @@ import io import logging import os +from unittest import mock from urllib.request import urlopen -import mock from flask import signals import elasticapm diff --git a/tests/contrib/opentracing/tests.py b/tests/contrib/opentracing/tests.py index 50970c269..e6899f028 100644 --- a/tests/contrib/opentracing/tests.py +++ b/tests/contrib/opentracing/tests.py @@ -34,8 +34,8 @@ opentracing = pytest.importorskip("opentracing") # isort:skip import sys +from unittest import mock -import mock from opentracing import Format import elasticapm diff --git a/tests/contrib/serverless/azurefunctions/azure_functions_tests.py b/tests/contrib/serverless/azurefunctions/azure_functions_tests.py index e2abbdcd3..91550a59f 100644 --- a/tests/contrib/serverless/azurefunctions/azure_functions_tests.py +++ b/tests/contrib/serverless/azurefunctions/azure_functions_tests.py @@ -33,9 +33,9 @@ import datetime import os +from unittest import mock import azure.functions as func -import mock import elasticapm from elasticapm.conf import constants diff --git a/tests/events/tests.py b/tests/events/tests.py index cd6cc6d3c..89d33ca3b 100644 --- a/tests/events/tests.py +++ b/tests/events/tests.py @@ -32,8 +32,9 @@ from __future__ import absolute_import +from unittest.mock import Mock + import pytest -from mock import Mock from elasticapm.events import Exception, Message diff --git a/tests/fixtures.py b/tests/fixtures.py index 25d21ee5d..deaa59a2d 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -45,10 +45,10 @@ import zlib from collections import defaultdict from typing import Optional +from unittest import mock from urllib.request import pathname2url import jsonschema -import mock import pytest from pytest_localserver.http import ContentServer from werkzeug.wrappers import Request, Response diff --git a/tests/instrumentation/base_tests.py b/tests/instrumentation/base_tests.py index e7564cff4..6841d8857 100644 --- a/tests/instrumentation/base_tests.py +++ b/tests/instrumentation/base_tests.py @@ -31,8 +31,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import logging +from unittest import mock -import mock import pytest import wrapt diff --git a/tests/instrumentation/transactions_store_tests.py b/tests/instrumentation/transactions_store_tests.py index 111c3b0c6..b2b483c2c 100644 --- a/tests/instrumentation/transactions_store_tests.py +++ b/tests/instrumentation/transactions_store_tests.py @@ -32,8 +32,8 @@ import logging import time from collections import defaultdict +from unittest import mock -import mock import pytest import elasticapm diff --git a/tests/instrumentation/urllib_tests.py b/tests/instrumentation/urllib_tests.py index fbf5fa44f..62dda0402 100644 --- a/tests/instrumentation/urllib_tests.py +++ b/tests/instrumentation/urllib_tests.py @@ -28,10 +28,10 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import urllib.parse +from unittest import mock from urllib.error import HTTPError, URLError from urllib.request import urlopen -import mock import pytest from elasticapm.conf import constants diff --git a/tests/metrics/base_tests.py b/tests/metrics/base_tests.py index 526e5079c..a9c51fb34 100644 --- a/tests/metrics/base_tests.py +++ b/tests/metrics/base_tests.py @@ -31,8 +31,8 @@ import logging import time from multiprocessing.dummy import Pool +from unittest import mock -import mock import pytest from elasticapm.conf import constants diff --git a/tests/metrics/breakdown_tests.py b/tests/metrics/breakdown_tests.py index 3e6b7ed9e..8572bcf6a 100644 --- a/tests/metrics/breakdown_tests.py +++ b/tests/metrics/breakdown_tests.py @@ -28,7 +28,8 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import mock +from unittest import mock + import pytest import elasticapm diff --git a/tests/processors/tests.py b/tests/processors/tests.py index 772eccf72..04c0b2eb0 100644 --- a/tests/processors/tests.py +++ b/tests/processors/tests.py @@ -34,8 +34,8 @@ import logging import os +from unittest import mock -import mock import pytest import elasticapm @@ -464,7 +464,7 @@ def test_drop_events_in_processor(elasticapm_client, caplog): assert shouldnt_be_called_processor.call_count == 0 assert elasticapm_client._transport.events[TRANSACTION][0] is None assert_any_record_contains( - caplog.records, "Dropped event of type transaction due to processor mock.mock.dropper", "elasticapm.transport" + caplog.records, "Dropped event of type transaction due to processor unittest.mock.dropper", "elasticapm.transport" ) diff --git a/tests/transports/test_base.py b/tests/transports/test_base.py index 2f77c3e95..37250cf7c 100644 --- a/tests/transports/test_base.py +++ b/tests/transports/test_base.py @@ -35,8 +35,8 @@ import sys import time import timeit +from unittest import mock -import mock import pytest from elasticapm.transport.base import Transport, TransportState diff --git a/tests/transports/test_urllib3.py b/tests/transports/test_urllib3.py index 78bc26200..88b308076 100644 --- a/tests/transports/test_urllib3.py +++ b/tests/transports/test_urllib3.py @@ -31,9 +31,9 @@ import os import time +from unittest import mock import certifi -import mock import pytest import urllib3.poolmanager from urllib3.exceptions import MaxRetryError, TimeoutError diff --git a/tests/utils/cloud_tests.py b/tests/utils/cloud_tests.py index 07c1f82e0..a365c2c93 100644 --- a/tests/utils/cloud_tests.py +++ b/tests/utils/cloud_tests.py @@ -29,8 +29,8 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os +from unittest import mock -import mock import urllib3 import elasticapm.utils.cloud diff --git a/tests/utils/compat_tests.py b/tests/utils/compat_tests.py index 9da7ac2f8..352d0bb48 100644 --- a/tests/utils/compat_tests.py +++ b/tests/utils/compat_tests.py @@ -28,7 +28,8 @@ # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -import mock +from unittest import mock + import pytest from elasticapm.utils import compat diff --git a/tests/utils/stacks/tests.py b/tests/utils/stacks/tests.py index 6f4d4094a..99c90c0b5 100644 --- a/tests/utils/stacks/tests.py +++ b/tests/utils/stacks/tests.py @@ -34,9 +34,9 @@ import importlib import os +from unittest.mock import Mock import pytest -from mock import Mock import elasticapm from elasticapm.conf import constants diff --git a/tests/utils/threading_tests.py b/tests/utils/threading_tests.py index 1c7329cd9..d9f2bf651 100644 --- a/tests/utils/threading_tests.py +++ b/tests/utils/threading_tests.py @@ -29,8 +29,8 @@ import platform import time +from unittest import mock -import mock import pytest from elasticapm.utils.threading import IntervalTimer