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

Commit 73aa547

Browse files
committed
added test
1 parent 6e50bc2 commit 73aa547

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/unit/test_bidi.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import logging
1717
import queue
1818
import threading
19+
import time
1920

2021
try:
2122
from unittest import mock
@@ -894,3 +895,26 @@ def close_side_effect():
894895

895896
# calling stop twice should not result in an error.
896897
consumer.stop()
898+
899+
def test_stop_error_logs(self, caplog):
900+
"""
901+
Closing the client should result in no internal error logs
902+
903+
https://github.com/googleapis/python-api-core/issues/788
904+
"""
905+
caplog.set_level(logging.DEBUG)
906+
bidi_rpc = mock.create_autospec(bidi.BidiRpc, instance=True)
907+
bidi_rpc.is_active = True
908+
on_response = mock.Mock(spec=["__call__"])
909+
910+
consumer = bidi.BackgroundConsumer(bidi_rpc, on_response)
911+
912+
consumer.start()
913+
consumer.stop()
914+
# let the background thread run for a while before exiting
915+
time.sleep(0.1)
916+
bidi_rpc.is_active = False
917+
# running thread should not result in error logs
918+
error_logs = [r.message for r in caplog.records if r.levelname == "ERROR"]
919+
assert not error_logs, f"Found unexpected ERROR logs: {error_logs}"
920+
bidi_rpc.is_active = False

0 commit comments

Comments
 (0)