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

Commit 424223d

Browse files
committed
test: remove thread-unsafe assertions for concurrent tests
1 parent c301cbc commit 424223d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tests/unit/test_spanner.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ def _read_helper(
333333
count=0,
334334
partition=None,
335335
directed_read_options=None,
336+
concurrent=False,
336337
):
337338
VALUES = [["bharney", 31], ["phred", 32]]
338339
VALUE_PBS = [[_make_value_pb(item) for item in row] for row in VALUES]
@@ -359,7 +360,8 @@ def _read_helper(
359360
result_sets[i].values.extend(VALUE_PBS[i])
360361

361362
api.streaming_read.return_value = _MockIterator(*result_sets)
362-
transaction._read_request_count = count
363+
if not concurrent:
364+
transaction._read_request_count = count
363365

364366
if partition is not None: # 'limit' and 'partition' incompatible
365367
result_set = transaction.read(
@@ -386,7 +388,8 @@ def _read_helper(
386388
directed_read_options=directed_read_options,
387389
)
388390

389-
self.assertEqual(transaction._read_request_count, count + 1)
391+
if not concurrent:
392+
self.assertEqual(transaction._read_request_count, count + 1)
390393

391394
self.assertEqual(list(result_set), VALUES)
392395
self.assertEqual(result_set.metadata, metadata_pb)
@@ -1105,13 +1108,13 @@ def test_transaction_for_concurrent_statement_should_begin_one_transaction_with_
11051108
threads.append(
11061109
threading.Thread(
11071110
target=self._read_helper,
1108-
kwargs={"transaction": transaction, "api": api},
1111+
kwargs={"transaction": transaction, "api": api, "concurrent": True},
11091112
)
11101113
)
11111114
threads.append(
11121115
threading.Thread(
11131116
target=self._read_helper,
1114-
kwargs={"transaction": transaction, "api": api},
1117+
kwargs={"transaction": transaction, "api": api, "concurrent": True},
11151118
)
11161119
)
11171120
for thread in threads:

0 commit comments

Comments
 (0)