refactor: Update test class to use IsolatedAsyncioTestCase

This commit is contained in:
stone-24tch3r (aider)
2024-09-22 22:43:05 +05:00
parent 52ad70bd79
commit 5b86fd384c

View File

@@ -1,11 +1,10 @@
import unittest
import uuid
import asyncio
from unittest.mock import patch
from core.trace_id_handler import TraceIdHandler
class TestTraceIdHandler(unittest.TestCase):
class TestTraceIdHandler(unittest.IsolatedAsyncioTestCase):
async def test_logging_scope(self):
async with TraceIdHandler.logging_scope():
@@ -24,9 +23,9 @@ class TestTraceIdHandler(unittest.TestCase):
self.assertEqual(TraceIdHandler.get_current_trace_id(), mock_uuid)
self.assertEqual(TraceIdHandler.get_current_trace_id(), mock_uuid) # Should return the same UUID
def test_get_current_trace_id_outside_scope(self):
async def test_get_current_trace_id_outside_scope(self):
self.assertIsNone(TraceIdHandler.get_current_trace_id())
if __name__ == '__main__':
asyncio.run(unittest.main())
unittest.main()