From 6292d0d0e5528dd296affba2b88c5b37e4f45811 Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Tue, 19 Nov 2019 11:09:46 -0800 Subject: [PATCH] Add a repr method for ClientOptions --- api_core/google/api_core/client_options.py | 3 +++ api_core/tests/unit/test_client_options.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/api_core/google/api_core/client_options.py b/api_core/google/api_core/client_options.py index 1144d2f62a37..137043f44df7 100644 --- a/api_core/google/api_core/client_options.py +++ b/api_core/google/api_core/client_options.py @@ -50,6 +50,9 @@ class ClientOptions(object): def __init__(self, api_endpoint=None): self.api_endpoint = api_endpoint + def __repr__(self): + return "ClientOptions: " + repr(self.__dict__) + def from_dict(options): """Construct a client options object from a dictionary. diff --git a/api_core/tests/unit/test_client_options.py b/api_core/tests/unit/test_client_options.py index 14cae9f24bfb..952adfce49d3 100644 --- a/api_core/tests/unit/test_client_options.py +++ b/api_core/tests/unit/test_client_options.py @@ -34,3 +34,9 @@ def test_from_dict_bad_argument(): client_options.from_dict( {"api_endpoint": "foo.googleapis.com", "bad_arg": "1234"} ) + + +def test_repr(): + options = client_options.ClientOptions(api_endpoint="foo.googleapis.com") + + assert repr(options) == "ClientOptions: {'api_endpoint': 'foo.googleapis.com'}"