@@ -133,17 +133,28 @@ def test_init_w_api_endpoint(creds):
133133 client_options = {"api_endpoint" : "testendpoint.google.com" }
134134 client = publisher .Client (client_options = client_options , credentials = creds )
135135
136+ # Behavior to include dns prefix changed in gRPCv1.63
137+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
138+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
139+ _EXPECTED_TARGET = "dns:///testendpoint.google.com:443"
140+ else :
141+ _EXPECTED_TARGET = "testendpoint.google.com:443"
136142 assert (client ._transport .grpc_channel ._channel .target ()).decode (
137143 "utf-8"
138- ) == "testendpoint.google.com:443"
144+ ) == _EXPECTED_TARGET
139145
140146
141147def test_init_w_empty_client_options (creds ):
142148 client = publisher .Client (client_options = {}, credentials = creds )
143-
149+ # Behavior to include dns prefix changed in gRPCv1.63
150+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
151+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
152+ _EXPECTED_TARGET = "dns:///pubsub.googleapis.com:443"
153+ else :
154+ _EXPECTED_TARGET = "pubsub.googleapis.com:443"
144155 assert (client ._transport .grpc_channel ._channel .target ()).decode (
145156 "utf-8"
146- ) == publisher_client . PublisherClient . SERVICE_ADDRESS
157+ ) == _EXPECTED_TARGET
147158
148159
149160def test_init_client_options_pass_through ():
@@ -182,7 +193,13 @@ def test_init_emulator(monkeypatch):
182193 # Sadly, there seems to be no good way to do this without poking at
183194 # the private API of gRPC.
184195 channel = client ._transport .publish ._channel
185- assert channel .target ().decode ("utf8" ) == "/foo/bar:123"
196+ # Behavior to include dns prefix changed in gRPCv1.63
197+ grpc_major , grpc_minor = [int (part ) for part in grpc .__version__ .split ("." )[0 :2 ]]
198+ if grpc_major > 1 or (grpc_major == 1 and grpc_minor >= 63 ):
199+ _EXPECTED_TARGET = "dns:////foo/bar:123"
200+ else :
201+ _EXPECTED_TARGET = "/foo/bar:123"
202+ assert channel .target ().decode ("utf8" ) == _EXPECTED_TARGET
186203
187204
188205def test_message_ordering_enabled (creds ):
0 commit comments