From 4f94c79350d7f794121614fa0970f7717ad78ddf Mon Sep 17 00:00:00 2001 From: Sijun Liu Date: Tue, 5 May 2020 12:31:03 -0700 Subject: [PATCH 1/2] fix: fix the usage so the tests can pass in g3 --- tests/transport/test_requests.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/transport/test_requests.py b/tests/transport/test_requests.py index d6770de73..d24b6f644 100644 --- a/tests/transport/test_requests.py +++ b/tests/transport/test_requests.py @@ -55,12 +55,12 @@ def make_guard(self, *args, **kwargs): def test_tracks_elapsed_time_w_numeric_timeout(self, frozen_time): with self.make_guard(timeout=10) as guard: - frozen_time.tick(delta=3.8) + frozen_time.tick(delta=datetime.timedelta(seconds=3.8)) assert guard.remaining_timeout == 6.2 def test_tracks_elapsed_time_w_tuple_timeout(self, frozen_time): with self.make_guard(timeout=(16, 19)) as guard: - frozen_time.tick(delta=3.8) + frozen_time.tick(delta=datetime.timedelta(seconds=3.8)) assert guard.remaining_timeout == (12.2, 15.2) def test_noop_if_no_timeout(self, frozen_time): @@ -72,13 +72,13 @@ def test_noop_if_no_timeout(self, frozen_time): def test_timeout_error_w_numeric_timeout(self, frozen_time): with pytest.raises(requests.exceptions.Timeout): with self.make_guard(timeout=10) as guard: - frozen_time.tick(delta=10.001) + frozen_time.tick(delta=datetime.timedelta(seconds=10.001)) assert guard.remaining_timeout == pytest.approx(-0.001) def test_timeout_error_w_tuple_timeout(self, frozen_time): with pytest.raises(requests.exceptions.Timeout): with self.make_guard(timeout=(11, 10)) as guard: - frozen_time.tick(delta=10.001) + frozen_time.tick(delta=datetime.timedelta(seconds=10.001)) assert guard.remaining_timeout == pytest.approx((0.999, -0.001)) def test_custom_timeout_error_type(self, frozen_time): @@ -87,7 +87,7 @@ class FooError(Exception): with pytest.raises(FooError): with self.make_guard(timeout=1, timeout_error_type=FooError): - frozen_time.tick(2) + frozen_time.tick(delta=datetime.timedelta(seconds=2)) def test_lets_suite_errors_bubble_up(self, frozen_time): with pytest.raises(IndexError): @@ -222,7 +222,7 @@ def test_request_default_timeout(self): authed_session.request("GET", self.TEST_URL) expected_timeout = google.auth.transport.requests._DEFAULT_TIMEOUT - assert patched_request.call_args.kwargs.get("timeout") == expected_timeout + assert patched_request.call_args[1]["timeout"] == expected_timeout def test_request_no_refresh(self): credentials = mock.Mock(wraps=CredentialsStub()) From 87c1b89b9f60562328248ac28cfbb473f3ff03a9 Mon Sep 17 00:00:00 2001 From: Sijun Liu Date: Tue, 5 May 2020 12:37:52 -0700 Subject: [PATCH 2/2] use frozenset --- google/auth/jwt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google/auth/jwt.py b/google/auth/jwt.py index 9248eb27f..24b92eb4f 100644 --- a/google/auth/jwt.py +++ b/google/auth/jwt.py @@ -67,7 +67,7 @@ _DEFAULT_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds _DEFAULT_MAX_CACHE_SIZE = 10 _ALGORITHM_TO_VERIFIER_CLASS = {"RS256": crypt.RSAVerifier} -_CRYPTOGRAPHY_BASED_ALGORITHMS = set(["ES256"]) +_CRYPTOGRAPHY_BASED_ALGORITHMS = frozenset(["ES256"]) if es256 is not None: # pragma: NO COVER _ALGORITHM_TO_VERIFIER_CLASS["ES256"] = es256.ES256Verifier