diff --git a/system_tests/vision.py b/system_tests/vision.py index 6388b4bb8600..62fae6de14ea 100644 --- a/system_tests/vision.py +++ b/system_tests/vision.py @@ -73,8 +73,8 @@ def _assert_likelihood(self, likelihood): Likelihood.VERY_UNLIKELY] self.assertIn(likelihood, levels) - def _maybe_http_skip(self, message): - if not Config.CLIENT._use_gax: + def _pb_not_implemented_skip(self, message): + if Config.CLIENT._use_gax: self.skipTest(message) @@ -195,7 +195,6 @@ def _assert_face(self, face): def test_detect_faces_content(self): client = Config.CLIENT - self._maybe_http_skip('gRPC is required for face detection.') with open(FACE_FILE, 'rb') as image_file: image = client.image(content=image_file.read()) faces = image.detect_faces() @@ -204,7 +203,6 @@ def test_detect_faces_content(self): self._assert_face(face) def test_detect_faces_gcs(self): - self._maybe_http_skip('gRPC is required for face detection.') bucket_name = Config.TEST_BUCKET.name blob_name = 'faces.jpg' blob = Config.TEST_BUCKET.blob(blob_name) @@ -221,7 +219,6 @@ def test_detect_faces_gcs(self): self._assert_face(face) def test_detect_faces_filename(self): - self._maybe_http_skip('gRPC is required for face detection.') client = Config.CLIENT image = client.image(filename=FACE_FILE) faces = image.detect_faces() @@ -296,7 +293,7 @@ class TestVisionClientLandmark(BaseVisionTestCase): DESCRIPTIONS = ('Mount Rushmore',) def setUp(self): - Config.CLIENT = vision.Client(use_gax=True) + Config.CLIENT = vision.Client() self.to_delete_by_case = [] def tearDown(self): @@ -353,7 +350,7 @@ def test_detect_landmark_filename(self): class TestVisionClientSafeSearch(BaseVisionTestCase): def setUp(self): - Config.CLIENT = vision.Client(use_gax=False) + Config.CLIENT = vision.Client() self.to_delete_by_case = [] def tearDown(self): @@ -370,7 +367,8 @@ def _assert_safe_search(self, safe_search): self._assert_likelihood(safe_search.violence) def test_detect_safe_search_content(self): - self._maybe_http_skip('gRPC is required for safe search detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for safe search detection.') client = Config.CLIENT with open(FACE_FILE, 'rb') as image_file: image = client.image(content=image_file.read()) @@ -380,7 +378,8 @@ def test_detect_safe_search_content(self): self._assert_safe_search(safe_search) def test_detect_safe_search_gcs(self): - self._maybe_http_skip('gRPC is required for safe search detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for safe search detection.') bucket_name = Config.TEST_BUCKET.name blob_name = 'faces.jpg' blob = Config.TEST_BUCKET.blob(blob_name) @@ -398,7 +397,8 @@ def test_detect_safe_search_gcs(self): self._assert_safe_search(safe_search) def test_detect_safe_search_filename(self): - self._maybe_http_skip('gRPC is required for safe search detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for safe search detection.') client = Config.CLIENT image = client.image(filename=FACE_FILE) safe_searches = image.detect_safe_search() @@ -470,7 +470,7 @@ def test_detect_text_filename(self): class TestVisionClientImageProperties(BaseVisionTestCase): def setUp(self): - Config.CLIENT = vision.Client(use_gax=False) + Config.CLIENT = vision.Client() self.to_delete_by_case = [] def tearDown(self): @@ -497,7 +497,8 @@ def _assert_properties(self, image_property): self.assertNotEqual(color_info.score, 0.0) def test_detect_properties_content(self): - self._maybe_http_skip('gRPC is required for text detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for text detection.') client = Config.CLIENT with open(FACE_FILE, 'rb') as image_file: image = client.image(content=image_file.read()) @@ -507,7 +508,8 @@ def test_detect_properties_content(self): self._assert_properties(image_property) def test_detect_properties_gcs(self): - self._maybe_http_skip('gRPC is required for text detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for text detection.') client = Config.CLIENT bucket_name = Config.TEST_BUCKET.name blob_name = 'faces.jpg' @@ -525,7 +527,8 @@ def test_detect_properties_gcs(self): self._assert_properties(image_property) def test_detect_properties_filename(self): - self._maybe_http_skip('gRPC is required for text detection.') + self._pb_not_implemented_skip( + 'gRPC not implemented for text detection.') client = Config.CLIENT image = client.image(filename=FACE_FILE) properties = image.detect_properties() diff --git a/vision/google/cloud/vision/client.py b/vision/google/cloud/vision/client.py index f41eedb345b7..89d9829d16fa 100644 --- a/vision/google/cloud/vision/client.py +++ b/vision/google/cloud/vision/client.py @@ -58,7 +58,7 @@ class Client(JSONClient): _vision_api_internal = None def __init__(self, project=None, credentials=None, http=None, - use_gax=False): + use_gax=None): super(Client, self).__init__( project=project, credentials=credentials, http=http) self._connection = Connection(