File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 4545
4646# Retrieve the version of this client library to be sent in the user-agent
4747# information of API calls.
48- _CLIENT_INFO = ClientInfo (client_library_version = metadata .version ("google-ads" ))
48+ try :
49+ _CLIENT_INFO = ClientInfo (
50+ client_library_version = metadata .version ("google-ads" )
51+ )
52+ except metadata .PackageNotFoundError :
53+ _CLIENT_INFO = ClientInfo ()
4954
5055# See options at grpc.github.io/grpc/core/group__grpc__arg__keys.html
5156_GRPC_CHANNEL_OPTIONS = [
Original file line number Diff line number Diff line change @@ -951,6 +951,16 @@ def test_load_http_proxy_from_string(self):
951951 use_cloud_org_for_api_access = None ,
952952 )
953953
954+ def test_client_info_package_not_found (self ):
955+ with mock .patch ("google.ads.googleads.client.metadata.version" ) as mock_version :
956+ mock_version .side_effect = Client .metadata .PackageNotFoundError
957+ from importlib import reload
958+ reload (Client )
959+ self .assertIsInstance (Client ._CLIENT_INFO , Client .ClientInfo )
960+ self .assertIsNone (Client ._CLIENT_INFO .client_library_version )
961+
962+ reload (Client )
963+
954964
955965class GoogleAdsClientTestFs (FileTestCase ):
956966 """Tests for the GoogleAdsClient class that require a fake filesystem."""
You can’t perform that action at this time.
0 commit comments