@@ -192,6 +192,7 @@ def test_wrap_method_with_overriding_retry_timeout_compression(unused_sleep):
192192 )
193193
194194
195+ @pytest .mark .skip (reason = "Known flaky due to floating point comparison. #866" )
195196def test_wrap_method_with_overriding_timeout_as_a_number ():
196197 method = mock .Mock (spec = ["__call__" ], return_value = 42 )
197198 default_retry = retry .Retry ()
@@ -202,7 +203,7 @@ def test_wrap_method_with_overriding_timeout_as_a_number():
202203
203204 # Using "result = wrapped_method(timeout=22)" fails since wrapped_method
204205 # does floating point calculations that results in 21.987.. instead of 22
205- result = wrapped_method (timeout = timeout . ConstantTimeout ( 22 ) )
206+ result = wrapped_method (timeout = 22 )
206207
207208 assert result == 42
208209
@@ -212,6 +213,24 @@ def test_wrap_method_with_overriding_timeout_as_a_number():
212213 assert actual_timeout == pytest .approx (22 , abs = 0.01 )
213214
214215
216+ def test_wrap_method_with_overriding_constant_timeout ():
217+ method = mock .Mock (spec = ["__call__" ], return_value = 42 )
218+ default_retry = retry .Retry ()
219+ default_timeout = timeout .ConstantTimeout (60 )
220+ wrapped_method = google .api_core .gapic_v1 .method .wrap_method (
221+ method , default_retry , default_timeout
222+ )
223+
224+ result = wrapped_method (timeout = timeout .ConstantTimeout (22 ))
225+
226+ assert result == 42
227+
228+ actual_timeout = method .call_args [1 ]["timeout" ]
229+ metadata = method .call_args [1 ]["metadata" ]
230+ assert metadata == mock .ANY
231+ assert actual_timeout == 22
232+
233+
215234def test_wrap_method_with_call ():
216235 method = mock .Mock ()
217236 mock_call = mock .Mock ()
0 commit comments