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

Commit bc85451

Browse files
authored
test: fix flaky sequencer unit tests (#187)
Patching the client under test should be done on an instance used in a test, not on the instance's class - patching the latter can cause all other instances of the same class to share the patched method, possibly interfering with the patched method's call count.
1 parent 6b9eec8 commit bc85451

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

tests/unit/pubsub_v1/publisher/test_publisher_client.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,7 @@ def test_wait_and_commit_sequencers():
435435

436436
# Mock out time so no sleep is actually done.
437437
with mock.patch.object(time, "sleep"):
438-
with mock.patch.object(
439-
publisher.Client, "_commit_sequencers"
440-
) as _commit_sequencers:
438+
with mock.patch.object(client, "_commit_sequencers") as _commit_sequencers:
441439
assert (
442440
client.publish("topic", b"bytestring body", ordering_key="") is not None
443441
)
@@ -456,9 +454,7 @@ def test_stopped_client_does_not_commit_sequencers():
456454

457455
# Mock out time so no sleep is actually done.
458456
with mock.patch.object(time, "sleep"):
459-
with mock.patch.object(
460-
publisher.Client, "_commit_sequencers"
461-
) as _commit_sequencers:
457+
with mock.patch.object(client, "_commit_sequencers") as _commit_sequencers:
462458
assert (
463459
client.publish("topic", b"bytestring body", ordering_key="") is not None
464460
)

0 commit comments

Comments
 (0)