From 6966a1a8b3bfb8a8a7c64bbfe937f8b71791a59b Mon Sep 17 00:00:00 2001 From: Victor Chudnovsky Date: Thu, 4 Sep 2025 12:34:11 -0700 Subject: [PATCH 1/3] fix: properly designate async test methods --- tests/asyncio/test_operation_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/asyncio/test_operation_async.py b/tests/asyncio/test_operation_async.py index 9d9fb5d25..154a42290 100644 --- a/tests/asyncio/test_operation_async.py +++ b/tests/asyncio/test_operation_async.py @@ -178,7 +178,7 @@ async def test_unexpected_result(unused_sleep): @pytest.mark.asyncio -def test_from_gapic(): +async def test_from_gapic(): operation_proto = make_operation_proto(done=True) operations_client = mock.create_autospec( operations_v1.OperationsClient, instance=True From 4dd85b3c93f8643237196bafe32147a55cfaf4ca Mon Sep 17 00:00:00 2001 From: Victor Chudnovsky Date: Thu, 4 Sep 2025 14:13:08 -0700 Subject: [PATCH 2/3] fix: fix async tests --- tests/asyncio/gapic/test_method_async.py | 6 +++++- tests/unit/gapic/test_method.py | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/asyncio/gapic/test_method_async.py b/tests/asyncio/gapic/test_method_async.py index cc4e7de83..3edf8b6d4 100644 --- a/tests/asyncio/gapic/test_method_async.py +++ b/tests/asyncio/gapic/test_method_async.py @@ -256,7 +256,11 @@ async def test_wrap_method_with_overriding_timeout_as_a_number(): result = await wrapped_method(timeout=22) assert result == 42 - method.assert_called_once_with(timeout=22, metadata=mock.ANY) + + actual_timeout = method.call_args[1]["timeout"] + metadata = method.call_args[1]["metadata"] + assert metadata == mock.ANY + assert actual_timeout == pytest.approx(22, abs=0.01) @pytest.mark.asyncio diff --git a/tests/unit/gapic/test_method.py b/tests/unit/gapic/test_method.py index 8896429cd..c27de64ea 100644 --- a/tests/unit/gapic/test_method.py +++ b/tests/unit/gapic/test_method.py @@ -201,7 +201,11 @@ def test_wrap_method_with_overriding_timeout_as_a_number(): result = wrapped_method(timeout=22) assert result == 42 - method.assert_called_once_with(timeout=22, metadata=mock.ANY) + + actual_timeout = method.call_args[1]["timeout"] + metadata = method.call_args[1]["metadata"] + assert metadata == mock.ANY + assert actual_timeout == pytest.approx(22, abs=0.01) def test_wrap_method_with_call(): From b03f06ddf70eac76ba6842a9cc3927e2dad52708 Mon Sep 17 00:00:00 2001 From: Victor Chudnovsky Date: Thu, 4 Sep 2025 14:47:17 -0700 Subject: [PATCH 3/3] fix: made additional test be an async method --- tests/asyncio/test_operation_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/asyncio/test_operation_async.py b/tests/asyncio/test_operation_async.py index 154a42290..5b2f012bf 100644 --- a/tests/asyncio/test_operation_async.py +++ b/tests/asyncio/test_operation_async.py @@ -85,7 +85,7 @@ async def test_constructor(): @pytest.mark.asyncio -def test_metadata(): +async def test_metadata(): expected_metadata = struct_pb2.Struct() future, _, _ = make_operation_future( [make_operation_proto(metadata=expected_metadata)]