Skip to content

Commit 6acb3a9

Browse files
authored
test: switch to regex rather than asserting against whole object (#497)
Fixes: #449, #492
1 parent 5dfb6af commit 6acb3a9

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

tests/unit/test_client_options.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from re import match
1516
import pytest
1617

1718
from google.api_core import client_options
@@ -144,10 +145,21 @@ def test_from_dict_bad_argument():
144145

145146

146147
def test_repr():
147-
options = client_options.ClientOptions(api_endpoint="foo.googleapis.com")
148-
149-
assert (
150-
repr(options)
151-
== "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None, 'client_encrypted_cert_source': None, 'api_key': None}"
152-
or "ClientOptions: {'client_encrypted_cert_source': None, 'client_cert_source': None, 'api_endpoint': 'foo.googleapis.com', 'api_key': None}"
148+
expected_keys = set(
149+
[
150+
"api_endpoint",
151+
"client_cert_source",
152+
"client_encrypted_cert_source",
153+
"quota_project_id",
154+
"credentials_file",
155+
"scopes",
156+
"api_key",
157+
"api_audience",
158+
]
153159
)
160+
options = client_options.ClientOptions(api_endpoint="foo.googleapis.com")
161+
options_repr = repr(options)
162+
options_keys = vars(options).keys()
163+
assert match(r"ClientOptions:", options_repr)
164+
assert match(r".*'api_endpoint': 'foo.googleapis.com'.*", options_repr)
165+
assert options_keys == expected_keys

0 commit comments

Comments
 (0)