@@ -102,10 +102,13 @@ def delete_rows(self):
102102
103103
104104class 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 ,
@@ -258,7 +260,7 @@ def test_mutation_set_cell(self, target, temp_rows):
258260 """Ensure cells can be set properly"""
259261 row_key = b"bulk_mutate"
260262 new_value = uuid .uuid4 ().hex .encode ()
261- row_key , mutation = self ._create_row_and_mutation (
263+ ( row_key , mutation ) = self ._create_row_and_mutation (
262264 target , temp_rows , new_value = new_value
263265 )
264266 target .mutate_row (row_key , mutation )
@@ -312,7 +314,7 @@ def test_bulk_mutations_set_cell(self, client, target, temp_rows):
312314 from google .cloud .bigtable .data .mutations import RowMutationEntry
313315
314316 new_value = uuid .uuid4 ().hex .encode ()
315- row_key , mutation = self ._create_row_and_mutation (
317+ ( row_key , mutation ) = self ._create_row_and_mutation (
316318 target , temp_rows , new_value = new_value
317319 )
318320 bulk_mutation = RowMutationEntry (row_key , [mutation ])
@@ -347,11 +349,11 @@ def test_mutations_batcher_context_manager(self, client, target, temp_rows):
347349 """test batcher with context manager. Should flush on exit"""
348350 from google .cloud .bigtable .data .mutations import RowMutationEntry
349351
350- new_value , new_value2 = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
351- row_key , mutation = self ._create_row_and_mutation (
352+ ( new_value , new_value2 ) = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
353+ ( row_key , mutation ) = self ._create_row_and_mutation (
352354 target , temp_rows , new_value = new_value
353355 )
354- row_key2 , mutation2 = self ._create_row_and_mutation (
356+ ( row_key2 , mutation2 ) = self ._create_row_and_mutation (
355357 target , temp_rows , new_value = new_value2
356358 )
357359 bulk_mutation = RowMutationEntry (row_key , [mutation ])
@@ -372,7 +374,7 @@ def test_mutations_batcher_timer_flush(self, client, target, temp_rows):
372374 from google .cloud .bigtable .data .mutations import RowMutationEntry
373375
374376 new_value = uuid .uuid4 ().hex .encode ()
375- row_key , mutation = self ._create_row_and_mutation (
377+ ( row_key , mutation ) = self ._create_row_and_mutation (
376378 target , temp_rows , new_value = new_value
377379 )
378380 bulk_mutation = RowMutationEntry (row_key , [mutation ])
@@ -394,12 +396,12 @@ def test_mutations_batcher_count_flush(self, client, target, temp_rows):
394396 """batch should flush after flush_limit_mutation_count mutations"""
395397 from google .cloud .bigtable .data .mutations import RowMutationEntry
396398
397- new_value , new_value2 = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
398- row_key , mutation = self ._create_row_and_mutation (
399+ ( new_value , new_value2 ) = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
400+ ( row_key , mutation ) = self ._create_row_and_mutation (
399401 target , temp_rows , new_value = new_value
400402 )
401403 bulk_mutation = RowMutationEntry (row_key , [mutation ])
402- row_key2 , mutation2 = self ._create_row_and_mutation (
404+ ( row_key2 , mutation2 ) = self ._create_row_and_mutation (
403405 target , temp_rows , new_value = new_value2
404406 )
405407 bulk_mutation2 = RowMutationEntry (row_key2 , [mutation2 ])
@@ -426,12 +428,12 @@ def test_mutations_batcher_bytes_flush(self, client, target, temp_rows):
426428 """batch should flush after flush_limit_bytes bytes"""
427429 from google .cloud .bigtable .data .mutations import RowMutationEntry
428430
429- new_value , new_value2 = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
430- row_key , mutation = self ._create_row_and_mutation (
431+ ( new_value , new_value2 ) = [uuid .uuid4 ().hex .encode () for _ in range (2 )]
432+ ( row_key , mutation ) = self ._create_row_and_mutation (
431433 target , temp_rows , new_value = new_value
432434 )
433435 bulk_mutation = RowMutationEntry (row_key , [mutation ])
434- row_key2 , mutation2 = self ._create_row_and_mutation (
436+ ( row_key2 , mutation2 ) = self ._create_row_and_mutation (
435437 target , temp_rows , new_value = new_value2
436438 )
437439 bulk_mutation2 = RowMutationEntry (row_key2 , [mutation2 ])
@@ -457,11 +459,11 @@ def test_mutations_batcher_no_flush(self, client, target, temp_rows):
457459
458460 new_value = uuid .uuid4 ().hex .encode ()
459461 start_value = b"unchanged"
460- row_key , mutation = self ._create_row_and_mutation (
462+ ( row_key , mutation ) = self ._create_row_and_mutation (
461463 target , temp_rows , start_value = start_value , new_value = new_value
462464 )
463465 bulk_mutation = RowMutationEntry (row_key , [mutation ])
464- row_key2 , mutation2 = self ._create_row_and_mutation (
466+ ( row_key2 , mutation2 ) = self ._create_row_and_mutation (
465467 target , temp_rows , start_value = start_value , new_value = new_value
466468 )
467469 bulk_mutation2 = RowMutationEntry (row_key2 , [mutation2 ])
0 commit comments