Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit b1c67b2

Browse files
committed
cleaned up test setup
1 parent a2070f9 commit b1c67b2

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

tests/system/data/test_system_async.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ async def delete_rows(self):
119119

120120
@CrossSync.convert_class(sync_name="TestSystem")
121121
class TestSystemAsync:
122+
def _make_client(self):
123+
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
124+
return CrossSync.DataClient(project=project)
125+
122126
@CrossSync.convert
123127
@CrossSync.pytest_fixture(scope="session")
124128
async def client(self):
125-
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
126-
async with CrossSync.DataClient(project=project) as client:
129+
async with self._make_client() as client:
127130
yield client
128131

129132
@CrossSync.convert
@@ -268,8 +271,7 @@ async def test_channel_refresh(self, table_id, instance_id, temp_rows):
268271
"""
269272
await temp_rows.add_row(b"row_key_1")
270273
await temp_rows.add_row(b"row_key_2")
271-
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
272-
client = CrossSync.DataClient(project=project)
274+
client = self._make_client()
273275
# start custom refresh task
274276
try:
275277
client._channel_refresh_task = CrossSync.create_task(

tests/system/data/test_system_autogen.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,13 @@ def delete_rows(self):
102102

103103

104104
class TestSystem:
105+
def _make_client(self):
106+
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
107+
return CrossSync._Sync_Impl.DataClient(project=project)
108+
105109
@pytest.fixture(scope="session")
106110
def client(self):
107-
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
108-
with CrossSync._Sync_Impl.DataClient(project=project) as client:
111+
with self._make_client() as client:
109112
yield client
110113

111114
@pytest.fixture(scope="session", params=TARGETS)
@@ -222,8 +225,7 @@ def test_channel_refresh(self, table_id, instance_id, temp_rows):
222225
to ensure new channel works"""
223226
temp_rows.add_row(b"row_key_1")
224227
temp_rows.add_row(b"row_key_2")
225-
project = os.getenv("GOOGLE_CLOUD_PROJECT") or None
226-
client = CrossSync._Sync_Impl.DataClient(project=project)
228+
client = self._make_client()
227229
try:
228230
client._channel_refresh_task = CrossSync._Sync_Impl.create_task(
229231
client._manage_channel,

0 commit comments

Comments
 (0)