File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed
Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def _read_json_file(path):
3232
3333def handle_configure (dry_run = False ):
3434 # TODO(https://github.com/googleapis/librarian/issues/466): Implement configure command.
35- print ("'configure' command executed." )
35+ logger . info ("'configure' command executed." )
3636
3737
3838def handle_generate (dry_run = False ):
@@ -42,19 +42,18 @@ def handle_generate(dry_run=False):
4242 try :
4343 request_data = _read_json_file (f"{ LIBRARIAN_DIR } /{ GENERATE_REQUEST_FILE } " )
4444 except Exception as e :
45- logger .error (e )
45+ logger .error (f"failed to read { LIBRARIAN_DIR } / { GENERATE_REQUEST_FILE } : { e } " )
4646 sys .exit (1 )
4747
48- # Print the data:
49- print (json .dumps (request_data , indent = 2 ))
48+ logger .info (json .dumps (request_data , indent = 2 ))
5049
5150 # TODO(https://github.com/googleapis/librarian/issues/448): Implement generate command.
52- print ("'generate' command executed." )
51+ logger . info ("'generate' command executed." )
5352
5453
5554def handle_build (dry_run = False ):
5655 # TODO(https://github.com/googleapis/librarian/issues/450): Implement build command.
57- print ("'build' command executed." )
56+ logger . info ("'build' command executed." )
5857
5958
6059if __name__ == "__main__" :
Original file line number Diff line number Diff line change 1515import os
1616import pytest
1717import json
18+ import logging
1819
1920from unittest .mock import mock_open
2021
@@ -58,15 +59,16 @@ def test_handle_generate_dry_run():
5859 handle_generate (dry_run = True )
5960
6061
61- def test_handle_generate_success (capsys , mock_generate_request_file ):
62+ def test_handle_generate_success (caplog , mock_generate_request_file ):
6263 """
6364 Tests the successful execution path of handle_generate.
6465 """
66+ caplog .set_level (logging .INFO )
67+
6568 handle_generate (dry_run = False )
6669
67- captured = capsys .readouterr ()
68- assert "google-cloud-language" in captured .out
69- assert "'generate' command executed." in captured .out
70+ assert "google-cloud-language" in caplog .text
71+ assert "'generate' command executed." in caplog .text
7072
7173
7274def test_handle_build_dry_run ():
You can’t perform that action at this time.
0 commit comments