8
8
import re
9
9
import time
10
10
import unittest
11
+ import unittest .mock
11
12
import urllib .error
12
13
13
- from . import mock
14
-
15
14
import shotgun_api3 as api
16
15
from shotgun_api3 .shotgun import ServerCapabilities
17
16
from shotgun_api3 .lib import six
@@ -133,12 +132,12 @@ def _setup_mock(self, s3_status_code_error=503):
133
132
"""Setup mocking on the ShotgunClient to stop it calling a live server"""
134
133
# Replace the function used to make the final call to the server
135
134
# eaiser than mocking the http connection + response
136
- self .sg ._http_request = mock .Mock (
135
+ self .sg ._http_request = unittest . mock .Mock (
137
136
spec = api .Shotgun ._http_request , return_value = ((200 , "OK" ), {}, None )
138
137
)
139
138
# Replace the function used to make the final call to the S3 server, and simulate
140
139
# 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 (
142
141
spec = api .Shotgun ._make_upload_request ,
143
142
side_effect = urllib .error .HTTPError (
144
143
"url" ,
@@ -152,12 +151,12 @@ def _setup_mock(self, s3_status_code_error=503):
152
151
# also replace the function that is called to get the http connection
153
152
# to avoid calling the server. OK to return a mock as we will not use
154
153
# it
155
- self .mock_conn = mock .Mock (spec = api .lib .httplib2 .Http )
154
+ self .mock_conn = unittest .Mock (spec = api .lib .httplib2 .Http )
156
155
# The Http objects connection property is a dict of connections
157
156
# it is holding
158
157
self .mock_conn .connections = dict ()
159
158
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 )
161
160
162
161
# create the server caps directly to say we have the correct version
163
162
self .sg ._server_caps = ServerCapabilities (
@@ -173,7 +172,7 @@ def _mock_http(self, data, headers=None, status=None):
173
172
"""
174
173
# test for a mock object rather than config.mock as some tests
175
174
# 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 ):
177
176
return
178
177
179
178
if not isinstance (data , str ):
0 commit comments