File tree 2 files changed +29
-3
lines changed
2 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 18
18
def run_quickstart ():
19
19
# [START vision_quickstart]
20
20
import io
21
+ import os
21
22
22
23
# Imports the Google Cloud client library
23
24
from google .cloud import vision
@@ -26,11 +27,15 @@ def run_quickstart():
26
27
vision_client = vision .Client ()
27
28
28
29
# 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' )
30
33
31
34
# 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 )
34
39
35
40
# Performs label detection on the image file
36
41
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