Skip to content

Commit

Permalink
Drop mock dependency; standardize on unittest.mock (#621)
Browse files Browse the repository at this point in the history
* Drop mock dependency; standardize on unittest.mock

Since we require Python 3.6+, unittest.mock is available, and it was
already used in some of the tests. Migrate any tests still using the
PyPI backport package “mock” to unittest.mock, and drop the dependency.

* Update CHANGELOG.md

Co-authored-by: Michael Penkov <m@penkov.dev>
  • Loading branch information
musicinmybrain and mpenkov authored May 25, 2021
1 parent a9b127d commit f92d1ed
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 1 addition & 4 deletions smart_open/tests/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

#
Expand Down
7 changes: 3 additions & 4 deletions smart_open/tests/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion smart_open/tests/test_smart_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion smart_open/tests/test_ssh.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-

import logging
import mock
import unittest
from unittest import mock

import smart_open.ssh

Expand Down

0 comments on commit f92d1ed

Please sign in to comment.