diff --git a/setup.py b/setup.py index a529ec3f5..0baa95e5b 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,6 @@ "coverage==5.*,>=5.0.3", "flake8==3.*,>=3.7.9", "isort==4.*,>=4.3.21", - "mock==3.*,>=3.0.5", "numpy==1.*,>=1.18.1", "preggy==1.*,>=1.4.4", "py3exiv2==0.*,>=0.7.1,!=0.7.2,!=0.8.0,!=0.9.3", diff --git a/tests/detectors/test_glasses_detector.py b/tests/detectors/test_glasses_detector.py index 17e558522..f9d2a8f5c 100644 --- a/tests/detectors/test_glasses_detector.py +++ b/tests/detectors/test_glasses_detector.py @@ -9,8 +9,8 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from os.path import abspath +from unittest import mock -import mock from preggy import expect from tornado.testing import gen_test diff --git a/tests/detectors/test_profile_detector.py b/tests/detectors/test_profile_detector.py index 94667674b..4253e798b 100644 --- a/tests/detectors/test_profile_detector.py +++ b/tests/detectors/test_profile_detector.py @@ -9,8 +9,8 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from os.path import abspath +from unittest import mock -import mock from preggy import expect from tornado.testing import gen_test diff --git a/tests/detectors/test_queued_detector.py b/tests/detectors/test_queued_detector.py index 30ea17f3b..8ce883e08 100644 --- a/tests/detectors/test_queued_detector.py +++ b/tests/detectors/test_queued_detector.py @@ -9,8 +9,8 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from json import loads +from unittest import mock -import mock from preggy import expect from redis import Redis from tornado.testing import gen_test diff --git a/tests/engines/test_base_engine.py b/tests/engines/test_base_engine.py index 44dfe0378..2eadd332a 100644 --- a/tests/engines/test_base_engine.py +++ b/tests/engines/test_base_engine.py @@ -12,10 +12,9 @@ from os.path import abspath, dirname, join from struct import pack -from unittest import TestCase +from unittest import TestCase, mock from xml.etree.ElementTree import ParseError -import mock from preggy import expect from thumbor.config import Config diff --git a/tests/handlers/test_base_handler_respecting_orientation.py b/tests/handlers/test_base_handler_respecting_orientation.py index 6a72be2d7..a123157be 100644 --- a/tests/handlers/test_base_handler_respecting_orientation.py +++ b/tests/handlers/test_base_handler_respecting_orientation.py @@ -13,11 +13,11 @@ from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.engines.pil import Engine from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_auto_png_to_jpg.py b/tests/handlers/test_base_handler_with_auto_png_to_jpg.py index f33143326..45d5c0199 100644 --- a/tests/handlers/test_base_handler_with_auto_png_to_jpg.py +++ b/tests/handlers/test_base_handler_with_auto_png_to_jpg.py @@ -8,15 +8,16 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -from mock import patch +from unittest.mock import patch + from libthumbor import CryptoURL from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import RequestParameters, ServerParameters from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_auto_webp.py b/tests/handlers/test_base_handler_with_auto_webp.py index 93c0722b7..29ab8162c 100644 --- a/tests/handlers/test_base_handler_with_auto_webp.py +++ b/tests/handlers/test_base_handler_with_auto_webp.py @@ -9,17 +9,17 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from shutil import which +from unittest.mock import patch from urllib.parse import quote +from libthumbor import CryptoURL from preggy import expect from tornado.testing import gen_test -from mock import patch -from libthumbor import CryptoURL +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, RequestParameters, ServerParameters from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_cover.py b/tests/handlers/test_base_handler_with_cover.py index b855ec403..7f3ec6cab 100644 --- a/tests/handlers/test_base_handler_with_cover.py +++ b/tests/handlers/test_base_handler_with_cover.py @@ -13,10 +13,10 @@ from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_different_storage_config.py b/tests/handlers/test_base_handler_with_different_storage_config.py index 1764dbb0d..82b67f54b 100644 --- a/tests/handlers/test_base_handler_with_different_storage_config.py +++ b/tests/handlers/test_base_handler_with_different_storage_config.py @@ -14,13 +14,13 @@ from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.engines.pil import Engine from thumbor.importer import Importer from thumbor.storages.file_storage import Storage as FileStorage from thumbor.storages.no_storage import Storage as NoStorage -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_engine_error.py b/tests/handlers/test_base_handler_with_engine_error.py index ca0166db8..6afa5d8d6 100644 --- a/tests/handlers/test_base_handler_with_engine_error.py +++ b/tests/handlers/test_base_handler_with_engine_error.py @@ -8,16 +8,17 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com +from unittest.mock import patch + import pytest -from mock import patch from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.engines.pil import Engine from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_gifv.py b/tests/handlers/test_base_handler_with_gifv.py index d398fb334..38a5891a7 100644 --- a/tests/handlers/test_base_handler_with_gifv.py +++ b/tests/handlers/test_base_handler_with_gifv.py @@ -14,10 +14,10 @@ from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.importer import Importer -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_http_headers.py b/tests/handlers/test_base_handler_with_http_headers.py index 07eb86bf9..9df4468cd 100644 --- a/tests/handlers/test_base_handler_with_http_headers.py +++ b/tests/handlers/test_base_handler_with_http_headers.py @@ -74,7 +74,7 @@ async def test_can_get_image_cors_header(self): class ImageOperationsWithCorsHeaderTestCase(BaseImagingTestCase): def get_context(self): - cfg = Config(SECURITY_KEY="ACME-SEC", ACCESS_CONTROL_ALLOW_ORIGIN_HEADER='*') + cfg = Config(SECURITY_KEY="ACME-SEC", ACCESS_CONTROL_ALLOW_ORIGIN_HEADER="*") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.ENABLE_ETAGS = False @@ -93,7 +93,7 @@ async def test_can_get_image_with_cors_header(self): expect(response.code).to_equal(200) expect(response.headers).to_include("Access-Control-Allow-Origin") - expect(response.headers['Access-Control-Allow-Origin']).to_equal('*') + expect(response.headers["Access-Control-Allow-Origin"]).to_equal("*") class ImageOperationsWithLastModifiedTestCase(BaseImagingTestCase): diff --git a/tests/handlers/test_base_handler_with_jpegtran.py b/tests/handlers/test_base_handler_with_jpegtran.py index e6d84f73e..92ca95b85 100644 --- a/tests/handlers/test_base_handler_with_jpegtran.py +++ b/tests/handlers/test_base_handler_with_jpegtran.py @@ -17,14 +17,14 @@ from preggy import expect from tornado.testing import gen_test -from thumbor.config import Config -from thumbor.context import Context, ServerParameters -from thumbor.importer import Importer from tests.handlers.test_base_handler import ( - BaseImagingTestCase, - JPEGTRAN_AVAILABLE, EXIFTOOL_AVAILABLE, + JPEGTRAN_AVAILABLE, + BaseImagingTestCase, ) +from thumbor.config import Config +from thumbor.context import Context, ServerParameters +from thumbor.importer import Importer # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_loader_error.py b/tests/handlers/test_base_handler_with_loader_error.py index 4f5ef5247..865bbde2e 100644 --- a/tests/handlers/test_base_handler_with_loader_error.py +++ b/tests/handlers/test_base_handler_with_loader_error.py @@ -11,11 +11,11 @@ from preggy import expect from tornado.testing import gen_test +from tests.handlers.test_base_handler import BaseImagingTestCase from thumbor.config import Config from thumbor.context import Context, ServerParameters from thumbor.importer import Importer from thumbor.loaders import LoaderResult -from tests.handlers.test_base_handler import BaseImagingTestCase # pylint: disable=broad-except,abstract-method,attribute-defined-outside-init,line-too-long,too-many-public-methods # pylint: disable=too-many-lines diff --git a/tests/handlers/test_base_handler_with_native_gif_handling.py b/tests/handlers/test_base_handler_with_native_gif_handling.py index cdcec4558..ee3085885 100644 --- a/tests/handlers/test_base_handler_with_native_gif_handling.py +++ b/tests/handlers/test_base_handler_with_native_gif_handling.py @@ -10,8 +10,8 @@ import os from os.path import dirname +from unittest.mock import Mock -from mock import Mock from preggy import expect from tornado.testing import gen_test diff --git a/tests/handlers/test_base_handler_with_result_storage.py b/tests/handlers/test_base_handler_with_result_storage.py index 05a2a9368..8be991afe 100644 --- a/tests/handlers/test_base_handler_with_result_storage.py +++ b/tests/handlers/test_base_handler_with_result_storage.py @@ -11,8 +11,8 @@ import os from os.path import dirname from shutil import which +from unittest.mock import Mock, patch -from mock import Mock, patch from preggy import expect from tornado.testing import gen_test diff --git a/tests/handlers/test_fetch_result.py b/tests/handlers/test_fetch_result.py index 9ffdd5875..f3680ecd7 100644 --- a/tests/handlers/test_fetch_result.py +++ b/tests/handlers/test_fetch_result.py @@ -8,7 +8,8 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -from mock import Mock +from unittest.mock import Mock + from preggy import expect from tests.base import TestCase diff --git a/tests/loaders/test_file_loader_http_fallback.py b/tests/loaders/test_file_loader_http_fallback.py index 78eb961b3..b7ee52876 100644 --- a/tests/loaders/test_file_loader_http_fallback.py +++ b/tests/loaders/test_file_loader_http_fallback.py @@ -9,8 +9,8 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from os.path import abspath, dirname, join +from unittest.mock import patch -from mock import patch from preggy import expect from tornado.testing import gen_test diff --git a/tests/metrics/test_default_metrics.py b/tests/metrics/test_default_metrics.py index 5bccbc4be..1942137a8 100644 --- a/tests/metrics/test_default_metrics.py +++ b/tests/metrics/test_default_metrics.py @@ -8,13 +8,13 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -import mock +from unittest import mock + from preggy import expect import thumbor.metrics -from thumbor.importer import Importer - from tests.base import TestCase +from thumbor.importer import Importer class DefaultMetricsTestCase(TestCase): diff --git a/tests/metrics/test_logger_metrics.py b/tests/metrics/test_logger_metrics.py index 147f82d4a..ae9d8f43d 100644 --- a/tests/metrics/test_logger_metrics.py +++ b/tests/metrics/test_logger_metrics.py @@ -10,12 +10,11 @@ from preggy import expect -from thumbor.context import Context -from thumbor.importer import Importer -from thumbor.config import Config import thumbor.metrics - from tests.base import TestCase +from thumbor.config import Config +from thumbor.context import Context +from thumbor.importer import Importer class LoggerMetricsTestCase(TestCase): diff --git a/tests/metrics/test_statsd_metrics.py b/tests/metrics/test_statsd_metrics.py index 904111acb..1d13ad11c 100644 --- a/tests/metrics/test_statsd_metrics.py +++ b/tests/metrics/test_statsd_metrics.py @@ -10,12 +10,11 @@ from preggy import expect -from thumbor.context import Context -from thumbor.importer import Importer -from thumbor.config import Config import thumbor.metrics - from tests.base import TestCase +from thumbor.config import Config +from thumbor.context import Context +from thumbor.importer import Importer class StatsdMetricsTestCase(TestCase): diff --git a/tests/optimizers/test_gifv.py b/tests/optimizers/test_gifv.py index 4dbce64ab..f78ca5999 100644 --- a/tests/optimizers/test_gifv.py +++ b/tests/optimizers/test_gifv.py @@ -9,9 +9,7 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from shutil import which -from unittest import TestCase - -import mock +from unittest import TestCase, mock from thumbor.config import Config from thumbor.context import Context, RequestParameters diff --git a/tests/optimizers/test_jpegtran.py b/tests/optimizers/test_jpegtran.py index 731a14389..82908b73a 100644 --- a/tests/optimizers/test_jpegtran.py +++ b/tests/optimizers/test_jpegtran.py @@ -8,9 +8,7 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -from unittest import TestCase - -import mock +from unittest import TestCase, mock from thumbor.config import Config from thumbor.context import Context, RequestParameters diff --git a/tests/result_storages/test_file_storage.py b/tests/result_storages/test_file_storage.py index 97b7e31b5..48f4a6490 100644 --- a/tests/result_storages/test_file_storage.py +++ b/tests/result_storages/test_file_storage.py @@ -11,8 +11,8 @@ import tempfile from datetime import datetime from os.path import abspath, dirname, join +from unittest import mock -import mock from preggy import expect from tornado.testing import gen_test diff --git a/tests/storages/test_file_storage.py b/tests/storages/test_file_storage.py index d9cf92e24..6d38832f1 100644 --- a/tests/storages/test_file_storage.py +++ b/tests/storages/test_file_storage.py @@ -12,8 +12,8 @@ from datetime import datetime from os.path import dirname, exists, join from tempfile import mkdtemp +from unittest import mock -import mock from preggy import expect from tornado.testing import gen_test diff --git a/tests/test_config.py b/tests/test_config.py index 6c3487908..4f2595ac8 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -9,12 +9,11 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com from os.path import expanduser -from unittest import TestCase -import mock +from unittest import TestCase, mock from preggy import expect -from thumbor.config import generate_config, format_value, Config +from thumbor.config import Config, format_value, generate_config class ConfigTestCase(TestCase): diff --git a/tests/test_context.py b/tests/test_context.py index 3d21a715a..3406b78b5 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -8,9 +8,8 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -from unittest import TestCase +from unittest import TestCase, mock -import mock from preggy import expect from thumbor.config import Config diff --git a/tests/test_point.py b/tests/test_point.py index 05e3494a1..bdd6a7917 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -10,9 +10,8 @@ from preggy import expect -from thumbor.point import FocalPoint - from tests.base import TestCase +from thumbor.point import FocalPoint class FocalPointTestCase(TestCase): diff --git a/tests/test_server.py b/tests/test_server.py index caaac20c3..c176d4887 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -8,9 +8,8 @@ # http://www.opensource.org/licenses/mit-license # Copyright (c) 2011 globo.com thumbor@googlegroups.com -from unittest import TestCase +from unittest import TestCase, mock -import mock from preggy import expect import thumbor.server diff --git a/tests/test_signal_handler.py b/tests/test_signal_handler.py index 552aecc27..5adb1b213 100644 --- a/tests/test_signal_handler.py +++ b/tests/test_signal_handler.py @@ -9,9 +9,7 @@ # Copyright (c) 2011 globo.com thumbor@googlegroups.com import signal -from unittest import TestCase - -import mock +from unittest import TestCase, mock from thumbor.signal_handler import setup_signal_handler, signal_handler diff --git a/tests/test_threadpool.py b/tests/test_threadpool.py index 89bd3f0a3..9b5c2c58b 100644 --- a/tests/test_threadpool.py +++ b/tests/test_threadpool.py @@ -11,8 +11,8 @@ # pylint: disable=protected-access from time import sleep +from unittest import mock -import mock import pytest from preggy import expect diff --git a/tests/test_url_composer.py b/tests/test_url_composer.py index bb5d9fb99..0edd22c1b 100644 --- a/tests/test_url_composer.py +++ b/tests/test_url_composer.py @@ -11,9 +11,8 @@ import optparse import sys from io import StringIO -from unittest import TestCase +from unittest import TestCase, mock -import mock from preggy import expect import thumbor.url_composer as composer diff --git a/tests/test_utils.py b/tests/test_utils.py index ba1c87ef4..0a692d618 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -10,9 +10,8 @@ import logging from shutil import which -from unittest import TestCase +from unittest import TestCase, mock -from mock import patch from preggy import expect from thumbor.utils import CONTENT_TYPE, EXTENSION, deprecated, logger @@ -57,7 +56,7 @@ def test_deprecated_logs_msg(): def test_func(): pass - with patch.object(logger, "warning") as mock_warn: + with mock.patch.object(logger, "warning") as mock_warn: test_func() mock_warn.assert_called_once_with( "Deprecated function %s%s", "test_func", "func2"