| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,6 +192,7 @@ def test_wrap_method_with_overriding_retry_timeout_compression(unused_sleep): | |||
| 192 | 192 | ) | |
| 193 | 193 | ||
| 194 | 194 | ||
| 195 | + @pytest.mark.skip(reason="Known flaky due to floating point comparison. #866") | ||
| 195 | 196 | def test_wrap_method_with_overriding_timeout_as_a_number(): | |
| 196 | 197 | method = mock.Mock(spec=["__call__"], return_value=42) | |
| 197 | 198 | default_retry = retry.Retry() | |
@@ -200,6 +201,8 @@ def test_wrap_method_with_overriding_timeout_as_a_number(): | |||
| 200 | 201 | method, default_retry, default_timeout | |
| 201 | 202 | ) | |
| 202 | 203 | ||
| 204 | + # Using "result = wrapped_method(timeout=22)" fails since wrapped_method | ||
| 205 | + # does floating point calculations that results in 21.987.. instead of 22 | ||
| 203 | 206 | result = wrapped_method(timeout=22) | |
| 204 | 207 | ||
| 205 | 208 | assert result == 42 | |
@@ -210,6 +213,24 @@ def test_wrap_method_with_overriding_timeout_as_a_number(): | |||
| 210 | 213 | assert actual_timeout == pytest.approx(22, abs=0.01) | |
| 211 | 214 | ||
| 212 | 215 | ||
| 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 | + | ||
| 213 | 234 | def test_wrap_method_with_call(): | |
| 214 | 235 | method = mock.Mock() | |
| 215 | 236 | mock_call = mock.Mock() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -90,8 +90,8 @@ def test__urlencode_param(key, value, expected): | |||
| 90 | 90 | def test__urlencode_param_caching_performance(): | |
| 91 | 91 | import time | |
| 92 | 92 | ||
| 93 | - key = "key" * 100 | ||
| 94 | - value = "value" * 100 | ||
| 93 | + key = "key" * 10000 | ||
| 94 | + value = "value" * 10000 | ||
| 95 | 95 | # time with empty cache | |
| 96 | 96 | start_time = time.perf_counter() | |
| 97 | 97 | routing_header._urlencode_param(key, value) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments