From 7b7bd8e32673dcea430134f1ed26025170b51d83 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 2 Jun 2026 10:41:17 -0700 Subject: [PATCH 1/3] add version pin to pytest-asyncio --- packages/google-cloud-bigtable/noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/google-cloud-bigtable/noxfile.py b/packages/google-cloud-bigtable/noxfile.py index e6ef8c1e9911..9929c1e2a068 100644 --- a/packages/google-cloud-bigtable/noxfile.py +++ b/packages/google-cloud-bigtable/noxfile.py @@ -40,7 +40,7 @@ "asyncmock", "pytest", "pytest-cov", - "pytest-asyncio", + "pytest-asyncio==1.3.0", RUFF_VERSION, ] UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] From 0b853992775bb336b87f27aa8611ec3341ff95ff Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 2 Jun 2026 10:49:10 -0700 Subject: [PATCH 2/3] use conftest instead --- packages/google-cloud-bigtable/noxfile.py | 2 +- .../tests/unit/conftest.py | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 packages/google-cloud-bigtable/tests/unit/conftest.py diff --git a/packages/google-cloud-bigtable/noxfile.py b/packages/google-cloud-bigtable/noxfile.py index 9929c1e2a068..e6ef8c1e9911 100644 --- a/packages/google-cloud-bigtable/noxfile.py +++ b/packages/google-cloud-bigtable/noxfile.py @@ -40,7 +40,7 @@ "asyncmock", "pytest", "pytest-cov", - "pytest-asyncio==1.3.0", + "pytest-asyncio", RUFF_VERSION, ] UNIT_TEST_EXTERNAL_DEPENDENCIES: List[str] = [] diff --git a/packages/google-cloud-bigtable/tests/unit/conftest.py b/packages/google-cloud-bigtable/tests/unit/conftest.py new file mode 100644 index 000000000000..529569445c0f --- /dev/null +++ b/packages/google-cloud-bigtable/tests/unit/conftest.py @@ -0,0 +1,24 @@ +import asyncio +import sys + +import pytest + + +@pytest.fixture(autouse=True) +def provide_loop_to_sync_grpc_tests(): + """ + GAPIC creates synchronous methods testing Asyncio transports. + If no global loop exists, `grpc.aio` engine crashes during initialization. + """ + try: + asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + yield + finally: + loop.close() + asyncio.set_event_loop(None) + else: + yield From 172e351fb085e3a3d20bbd2fa02d70ab797e8d97 Mon Sep 17 00:00:00 2001 From: Daniel Sanche Date: Tue, 2 Jun 2026 10:54:04 -0700 Subject: [PATCH 3/3] fixed lint; added copyright --- .../google-cloud-bigtable/tests/unit/conftest.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/google-cloud-bigtable/tests/unit/conftest.py b/packages/google-cloud-bigtable/tests/unit/conftest.py index 529569445c0f..59ff118aa71f 100644 --- a/packages/google-cloud-bigtable/tests/unit/conftest.py +++ b/packages/google-cloud-bigtable/tests/unit/conftest.py @@ -1,5 +1,18 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import asyncio -import sys import pytest