diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c44a8a9..ff553518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Add warning for recently deprecated s3 parameters (PR [#618](https://github.com/RaRe-Technologies/smart_open/pull/618), [@mpenkov](https://github.com/mpenkov)) - Add new top-level compression parameter (PR [#609](https://github.com/RaRe-Technologies/smart_open/pull/609), [@dmcguire81](https://github.com/dmcguire81)) +- Drop mock dependency; standardize on unittest.mock (PR [#621](https://github.com/RaRe-Technologies/smart_open/pull/621), [@musicinmybrain](https://github.com/musicinmybrain)) # 5.0.0, 30 Mar 2021 diff --git a/setup.py b/setup.py index 41ff36c9..11d9b560 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,6 @@ def read(fname): all_deps = aws_deps + gcs_deps + azure_deps + http_deps tests_require = all_deps + [ - 'mock', 'moto[server]==1.3.14', # Older versions of moto appear broken 'pathlib2', 'responses', diff --git a/smart_open/tests/test_gcs.py b/smart_open/tests/test_gcs.py index 583f48e4..052d10e3 100644 --- a/smart_open/tests/test_gcs.py +++ b/smart_open/tests/test_gcs.py @@ -13,10 +13,7 @@ import time import uuid import unittest -try: - from unittest import mock -except ImportError: - import mock +from unittest import mock import warnings from collections import OrderedDict diff --git a/smart_open/tests/test_hdfs.py b/smart_open/tests/test_hdfs.py index 9f22acf9..c38f8bdf 100644 --- a/smart_open/tests/test_hdfs.py +++ b/smart_open/tests/test_hdfs.py @@ -10,10 +10,9 @@ import os.path as P import subprocess import unittest +from unittest import mock import sys -import mock - import smart_open.hdfs # diff --git a/smart_open/tests/test_s3.py b/smart_open/tests/test_s3.py index 6e1ba228..f31bc1d7 100644 --- a/smart_open/tests/test_s3.py +++ b/smart_open/tests/test_s3.py @@ -15,13 +15,12 @@ import unittest import warnings from contextlib import contextmanager -from unittest.mock import patch +from unittest import mock import sys import boto3 import botocore.client import botocore.endpoint -import mock import moto import smart_open @@ -108,7 +107,7 @@ def mock_get(*args, **kwargs): error_response['Message'] = 'The requested range is not satisfiable' raise - with patch('smart_open.s3._get', new=mock_get): + with mock.patch('smart_open.s3._get', new=mock_get): yield @@ -123,7 +122,7 @@ def mock_make_request(self, operation_model, *args, **kwargs): api_calls[operation_model.name] += 1 return _real_make_request(self, operation_model, *args, **kwargs) - patcher = patch('botocore.endpoint.Endpoint.make_request', new=mock_make_request) + patcher = mock.patch('botocore.endpoint.Endpoint.make_request', new=mock_make_request) patcher.start() try: yield api_calls diff --git a/smart_open/tests/test_smart_open.py b/smart_open/tests/test_smart_open.py index aa11249e..db0bc7a1 100644 --- a/smart_open/tests/test_smart_open.py +++ b/smart_open/tests/test_smart_open.py @@ -17,10 +17,10 @@ from smart_open.compression import INFER_FROM_EXTENSION, NO_COMPRESSION import tempfile import unittest +from unittest import mock import warnings import boto3 -import mock from moto import mock_s3 import parameterizedtestcase import pytest diff --git a/smart_open/tests/test_ssh.py b/smart_open/tests/test_ssh.py index 92da2716..18a8f166 100644 --- a/smart_open/tests/test_ssh.py +++ b/smart_open/tests/test_ssh.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- import logging -import mock import unittest +from unittest import mock import smart_open.ssh