From c4620218aa09cb27f355d26c6556a3aea07dc684 Mon Sep 17 00:00:00 2001 From: Teknique Date: Fri, 21 Jul 2023 17:35:39 -0700 Subject: [PATCH] Worked around globals --- veilid-python/tests/test_routing_context.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/veilid-python/tests/test_routing_context.py b/veilid-python/tests/test_routing_context.py index 1d602b3b..9b6f95f9 100644 --- a/veilid-python/tests/test_routing_context.py +++ b/veilid-python/tests/test_routing_context.py @@ -143,14 +143,12 @@ async def test_routing_context_app_call_loopback(): async def test_routing_context_app_message_loopback_big_packets(): app_message_queue: asyncio.Queue = asyncio.Queue() - global got_message - got_message = 0 + count_hack = [0] async def app_message_queue_update_callback(update: veilid.VeilidUpdate): if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE: - global got_message - got_message += 1 - sys.stdout.write("{} ".format(got_message)) + count_hack[0] += 1 + print(f"{count_hack[0]} ", end="") await app_message_queue.put(update) sent_messages: set[bytes] = set() @@ -198,8 +196,7 @@ async def test_routing_context_app_message_loopback_big_packets(): @pytest.mark.asyncio async def test_routing_context_app_call_loopback_big_packets(): - global got_message - got_message = 0 + count_hack = [0] app_call_queue: asyncio.Queue = asyncio.Queue() @@ -211,11 +208,8 @@ async def test_routing_context_app_call_loopback_big_packets(): while True: update = await app_call_queue.get() - global got_message - got_message += 1 - - sys.stdout.write("{} ".format(got_message)) - sys.stdout.flush() + count_hack[0] += 1 + print(f"{count_hack[0]} ", end="", flush=True) await api.app_call_reply(update.detail.call_id, update.detail.message)