@@ -66,17 +66,32 @@ def test_init_w_api_endpoint(creds):
6666 client_options = {"api_endpoint" : "testendpoint.google.com" }
6767 client = subscriber .Client (client_options = client_options , credentials = creds )
6868
69- assert (client ._transport .grpc_channel ._channel .target ()).decode (
70- "utf-8"
71- ) == "testendpoint.google.com:443"
69+ # Behavior to include dns prefix changed in gRPCv1.63
70+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
71+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
72+ assert (client ._transport .grpc_channel ._channel .target ()).decode (
73+ "utf-8"
74+ ) == "dns:///testendpoint.google.com:443"
75+ else :
76+ assert (client ._transport .grpc_channel ._channel .target ()).decode (
77+ "utf-8"
78+ ) == "testendpoint.google.com:443"
7279
7380
7481def test_init_w_empty_client_options (creds ):
7582 client = subscriber .Client (client_options = {}, credentials = creds )
76-
77- assert (client ._transport .grpc_channel ._channel .target ()).decode (
78- "utf-8"
79- ) == subscriber_client .SubscriberClient .SERVICE_ADDRESS
83+
84+
85+ # Behavior to include dns prefix changed in gRPCv1.63
86+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
87+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
88+ assert (client ._transport .grpc_channel ._channel .target ()).decode (
89+ "utf-8"
90+ ) == "dns:///pubsub.googleapis.com:443"
91+ else :
92+ assert (client ._transport .grpc_channel ._channel .target ()).decode (
93+ "utf-8"
94+ ) == "pubsub.googleapis.com:443"
8095
8196
8297def test_init_client_options_pass_through ():
@@ -115,7 +130,12 @@ def test_init_emulator(monkeypatch):
115130 # Sadly, there seems to be no good way to do this without poking at
116131 # the private API of gRPC.
117132 channel = client ._transport .pull ._channel
118- assert channel .target ().decode ("utf8" ) == "/baz/bacon:123"
133+ # Behavior to include dns prefix changed in gRPCv1.63
134+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
135+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
136+ assert channel .target ().decode ("utf8" ) == "dns:////baz/bacon:123"
137+ else :
138+ assert channel .target ().decode ("utf8" ) == "baz/bacon:123"
119139
120140
121141def test_class_method_factory ():
0 commit comments