@@ -82,17 +82,19 @@ def test_image_with_client(self):
8282 self .assertIsInstance (image , Image )
8383
8484 def test_multiple_detection_from_content (self ):
85+ import copy
8586 from google .cloud .vision .feature import Feature
8687 from google .cloud .vision .feature import FeatureTypes
8788 from unit_tests ._fixtures import LABEL_DETECTION_RESPONSE
8889 from unit_tests ._fixtures import LOGO_DETECTION_RESPONSE
89- RETURNED = LABEL_DETECTION_RESPONSE
90- LOGOS = LOGO_DETECTION_RESPONSE ['responses' ][0 ]['logoAnnotations' ]
91- RETURNED ['responses' ][0 ]['logoAnnotations' ] = LOGOS
90+
91+ returned = copy .deepcopy (LABEL_DETECTION_RESPONSE )
92+ logos = copy .deepcopy (LOGO_DETECTION_RESPONSE ['responses' ][0 ])
93+ returned ['responses' ][0 ]['logoAnnotations' ] = logos ['logoAnnotations' ]
9294
9395 credentials = _Credentials ()
9496 client = self ._make_one (project = PROJECT , credentials = credentials )
95- client ._connection = _Connection (RETURNED )
97+ client ._connection = _Connection (returned )
9698
9799 limit = 2
98100 label_feature = Feature (FeatureTypes .LABEL_DETECTION , limit )
@@ -103,19 +105,26 @@ def test_multiple_detection_from_content(self):
103105
104106 self .assertEqual (len (items .logos ), 2 )
105107 self .assertEqual (len (items .labels ), 3 )
106- self .assertEqual (items .logos [0 ].description , 'Brand1' )
107- self .assertEqual (items .logos [0 ].score , 0.63192177 )
108- self .assertEqual (items .logos [1 ].description , 'Brand2' )
109- self .assertEqual (items .logos [1 ].score , 0.5492993 )
110-
111- self .assertEqual (items .labels [0 ].description , 'automobile' )
112- self .assertEqual (items .labels [0 ].score , 0.9776855 )
113- self .assertEqual (items .labels [1 ].description , 'vehicle' )
114- self .assertEqual (items .labels [1 ].score , 0.947987 )
115- self .assertEqual (items .labels [2 ].description , 'truck' )
116- self .assertEqual (items .labels [2 ].score , 0.88429511 )
117-
118- image_request = client ._connection ._requested [0 ]['data' ]['requests' ][0 ]
108+ first_logo = items .logos [0 ]
109+ second_logo = items .logos [1 ]
110+ self .assertEqual (first_logo .description , 'Brand1' )
111+ self .assertEqual (first_logo .score , 0.63192177 )
112+ self .assertEqual (second_logo .description , 'Brand2' )
113+ self .assertEqual (second_logo .score , 0.5492993 )
114+
115+ first_label = items .labels [0 ]
116+ second_label = items .labels [1 ]
117+ third_label = items .labels [2 ]
118+ self .assertEqual (first_label .description , 'automobile' )
119+ self .assertEqual (first_label .score , 0.9776855 )
120+ self .assertEqual (second_label .description , 'vehicle' )
121+ self .assertEqual (second_label .score , 0.947987 )
122+ self .assertEqual (third_label .description , 'truck' )
123+ self .assertEqual (third_label .score , 0.88429511 )
124+
125+ requested = client ._connection ._requested
126+ requests = requested [0 ]['data' ]['requests' ]
127+ image_request = requests [0 ]
119128 label_request = image_request ['features' ][0 ]
120129 logo_request = image_request ['features' ][1 ]
121130
@@ -171,7 +180,7 @@ def test_face_detection_from_content_no_results(self):
171180
172181 image = client .image (content = IMAGE_CONTENT )
173182 faces = image .detect_faces (limit = 5 )
174- self .assertEqual (faces , [] )
183+ self .assertEqual (faces , () )
175184 self .assertEqual (len (faces ), 0 )
176185 image_request = client ._connection ._requested [0 ]['data' ]['requests' ][0 ]
177186
@@ -211,7 +220,7 @@ def test_label_detection_no_results(self):
211220
212221 image = client .image (content = IMAGE_CONTENT )
213222 labels = image .detect_labels ()
214- self .assertEqual (labels , [] )
223+ self .assertEqual (labels , () )
215224 self .assertEqual (len (labels ), 0 )
216225
217226 def test_landmark_detection_from_source (self ):
@@ -264,7 +273,7 @@ def test_landmark_detection_no_results(self):
264273
265274 image = client .image (content = IMAGE_CONTENT )
266275 landmarks = image .detect_landmarks ()
267- self .assertEqual (landmarks , [] )
276+ self .assertEqual (landmarks , () )
268277 self .assertEqual (len (landmarks ), 0 )
269278
270279 def test_logo_detection_from_source (self ):
@@ -353,7 +362,7 @@ def test_safe_search_no_results(self):
353362
354363 image = client .image (content = IMAGE_CONTENT )
355364 safe_search = image .detect_safe_search ()
356- self .assertEqual (safe_search , [] )
365+ self .assertEqual (safe_search , () )
357366 self .assertEqual (len (safe_search ), 0 )
358367
359368 def test_image_properties_detection_from_source (self ):
@@ -389,7 +398,7 @@ def test_image_properties_no_results(self):
389398
390399 image = client .image (content = IMAGE_CONTENT )
391400 image_properties = image .detect_properties ()
392- self .assertEqual (image_properties , [] )
401+ self .assertEqual (image_properties , () )
393402 self .assertEqual (len (image_properties ), 0 )
394403
395404
0 commit comments