Skip to content

Commit

Permalink
modify test_code
Browse files Browse the repository at this point in the history
  • Loading branch information
bourbonkk committed Oct 10, 2023
1 parent bf76ff3 commit 15c0375
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,24 @@ def tearDown(self):
AsyncioInstrumentor().uninstrument()

@pytest.mark.asyncio
def test_asyncio_loop_ensure_future(self):
async def test_asyncio_loop_ensure_future(self):
"""
async_func is not traced because it is not set in the environment variable
"""
loop = asyncio.get_event_loop()
task = asyncio.ensure_future(async_func())
loop.run_until_complete(task)
await task

spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 0)

@pytest.mark.asyncio
def test_asyncio_ensure_future_with_future(self):
async def test_asyncio_ensure_future_with_future(self):
with self._tracer.start_as_current_span("root") as root:
loop = asyncio.get_event_loop()

future = asyncio.Future()
future.set_result(1)
task = asyncio.ensure_future(future)
loop.run_until_complete(task)
await task

spans = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans), 2)
Expand Down

0 comments on commit 15c0375

Please sign in to comment.