test: switch to regex rather than asserting against whole object (#497)
Fixes: #449, #492
diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py
index d56a1b3..336ceea 100644
--- a/tests/unit/test_client_options.py
+++ b/tests/unit/test_client_options.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from re import match
import pytest
from google.api_core import client_options
@@ -144,10 +145,21 @@
def test_repr():
- options = client_options.ClientOptions(api_endpoint="foo.googleapis.com")
-
- assert (
- repr(options)
- == "ClientOptions: {'api_endpoint': 'foo.googleapis.com', 'client_cert_source': None, 'client_encrypted_cert_source': None, 'api_key': None}"
- or "ClientOptions: {'client_encrypted_cert_source': None, 'client_cert_source': None, 'api_endpoint': 'foo.googleapis.com', 'api_key': None}"
+ expected_keys = set(
+ [
+ "api_endpoint",
+ "client_cert_source",
+ "client_encrypted_cert_source",
+ "quota_project_id",
+ "credentials_file",
+ "scopes",
+ "api_key",
+ "api_audience",
+ ]
)
+ options = client_options.ClientOptions(api_endpoint="foo.googleapis.com")
+ options_repr = repr(options)
+ options_keys = vars(options).keys()
+ assert match(r"ClientOptions:", options_repr)
+ assert match(r".*'api_endpoint': 'foo.googleapis.com'.*", options_repr)
+ assert options_keys == expected_keys