Skip to content

Commit f533371

Browse files
committed
Remove deprecated backported mock module
1 parent 33e5200 commit f533371

File tree

6 files changed

+30
-1026
lines changed

6 files changed

+30
-1026
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010

1111
[flake8]
1212
max-line-length = 120
13-
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py,tests/mock.py
13+
exclude = shotgun_api3/lib/httplib2/*,shotgun_api3/lib/six.py,tests/httplib2test.py

tests/base.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
import re
99
import time
1010
import unittest
11+
import unittest.mock
1112
import urllib.error
1213

13-
from . import mock
14-
1514
import shotgun_api3 as api
1615
from shotgun_api3.shotgun import ServerCapabilities
1716
from shotgun_api3.lib import six
@@ -133,12 +132,12 @@ def _setup_mock(self, s3_status_code_error=503):
133132
"""Setup mocking on the ShotgunClient to stop it calling a live server"""
134133
# Replace the function used to make the final call to the server
135134
# eaiser than mocking the http connection + response
136-
self.sg._http_request = mock.Mock(
135+
self.sg._http_request = unittest.mock.Mock(
137136
spec=api.Shotgun._http_request, return_value=((200, "OK"), {}, None)
138137
)
139138
# Replace the function used to make the final call to the S3 server, and simulate
140139
# the exception HTTPError raised with 503 status errors
141-
self.sg._make_upload_request = mock.Mock(
140+
self.sg._make_upload_request = unittest.mock.Mock(
142141
spec=api.Shotgun._make_upload_request,
143142
side_effect=urllib.error.HTTPError(
144143
"url",
@@ -152,12 +151,12 @@ def _setup_mock(self, s3_status_code_error=503):
152151
# also replace the function that is called to get the http connection
153152
# to avoid calling the server. OK to return a mock as we will not use
154153
# it
155-
self.mock_conn = mock.Mock(spec=api.lib.httplib2.Http)
154+
self.mock_conn = unittest.Mock(spec=api.lib.httplib2.Http)
156155
# The Http objects connection property is a dict of connections
157156
# it is holding
158157
self.mock_conn.connections = dict()
159158
self.sg._connection = self.mock_conn
160-
self.sg._get_connection = mock.Mock(return_value=self.mock_conn)
159+
self.sg._get_connection = unittest.mock.Mock(return_value=self.mock_conn)
161160

162161
# create the server caps directly to say we have the correct version
163162
self.sg._server_caps = ServerCapabilities(
@@ -173,7 +172,7 @@ def _mock_http(self, data, headers=None, status=None):
173172
"""
174173
# test for a mock object rather than config.mock as some tests
175174
# force the mock to be created
176-
if not isinstance(self.sg._http_request, mock.Mock):
175+
if not isinstance(self.sg._http_request, unittest.mock.Mock):
177176
return
178177

179178
if not isinstance(data, str):

0 commit comments

Comments
 (0)