diff --git a/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial.py b/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial.py index c4a8434502ba..a9ea9328f49a 100644 --- a/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial.py +++ b/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial.py @@ -56,6 +56,7 @@ def pic_to_text(infile): # For less dense text, use text_detection response = client.document_text_detection(image=image) text = response.full_text_annotation.text + print("Detected text: {}".format(text)) return text # [END translate_hybrid_vision] diff --git a/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py b/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py index 8df7cc351b73..5643968842f2 100644 --- a/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py +++ b/translation/samples/snippets/hybrid_glossaries/hybrid_tutorial_test.py @@ -13,7 +13,6 @@ # limitations under the License. import os -import re import sys import uuid @@ -29,11 +28,13 @@ # VISION TESTS -def test_vision_standard_format(): +def test_vision_standard_format(capsys): # Generate text using Vision API - text = pic_to_text('resources/standard_format.jpeg') + pic_to_text('resources/standard_format.jpeg') + out, err = capsys.readouterr() - assert re.match(r"This\s?is\s?a\s?test!\s?", text) + assert 'Detected text:' in out + assert 'test!' in out def test_vision_non_standard_format():