diff --git a/vision/unit_tests/test__gax.py b/vision/unit_tests/test__gax.py index 57ed8070a12d3..cf1172661f637 100644 --- a/vision/unit_tests/test__gax.py +++ b/vision/unit_tests/test__gax.py @@ -17,11 +17,6 @@ import mock -def _make_credentials(): - import google.auth.credentials - return mock.Mock(spec=google.auth.credentials.Credentials) - - class TestGAXClient(unittest.TestCase): def _get_target_class(self): from google.cloud.vision._gax import _GAPICVisionAPI @@ -31,13 +26,11 @@ def _make_one(self, *args, **kwargs): return self._get_target_class()(*args, **kwargs) def test_ctor(self): - from google.cloud.gapic.vision.v1 import image_annotator_client - - client = mock.Mock(credentials=_make_credentials()) - api = self._make_one(client) + client = mock.Mock() + with mock.patch('google.cloud.vision._gax.image_annotator_client.' + 'ImageAnnotatorClient'): + api = self._make_one(client) self.assertIs(api._client, client) - self.assertIsInstance(api._api, - image_annotator_client.ImageAnnotatorClient) class TestToGAPICFeature(unittest.TestCase): diff --git a/vision/unit_tests/test_client.py b/vision/unit_tests/test_client.py index bd6e4791ac73b..a0d3f101c3f1c 100644 --- a/vision/unit_tests/test_client.py +++ b/vision/unit_tests/test_client.py @@ -59,8 +59,9 @@ def test_make_gax_client(self): from google.cloud.vision._gax import _GAPICVisionAPI credentials = _make_credentials() - client = self._make_one(project=PROJECT, credentials=credentials, - use_gax=None) + with mock.patch('google.cloud.vision.client._GAPICVisionAPI'): + client = self._make_one(project=PROJECT, credentials=credentials, + use_gax=None) client._connection = _Connection() self.assertIsInstance(client._vision_api, _GAPICVisionAPI)