File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1818def run_quickstart ():
1919 # [START vision_quickstart]
2020 import io
21+ import os
2122
2223 # Imports the Google Cloud client library
2324 from google .cloud import vision
@@ -26,11 +27,15 @@ def run_quickstart():
2627 vision_client = vision .Client ()
2728
2829 # The name of the image file to annotate
29- fileName = './resources/wakeupcat.jpg'
30+ file_name = os .path .join (
31+ os .path .dirname (__file__ ),
32+ 'resources/wakeupcat.jpg' )
3033
3134 # Loads the image into memory
32- with io .open (fileName , 'rb' ) as image_file :
33- image = vision_client .image (content = image_file .read ())
35+ with io .open (file_name , 'rb' ) as image_file :
36+ content = image_file .read ()
37+ image = vision_client .image (
38+ content = content )
3439
3540 # Performs label detection on the image file
3641 labels = image .detect_labels ()
Original file line number Diff line number Diff line change 1+ # Copyright 2016 Google Inc. All Rights Reserved.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ import quickstart
16+
17+
18+ def test_quickstart (capsys ):
19+ quickstart .run_quickstart ()
20+ out , _ = capsys .readouterr ()
21+ assert 'Labels' in out
You can’t perform that action at this time.
0 commit comments