Skip to content

Commit 15c0375

Browse files
committed
modify test_code
1 parent bf76ff3 commit 15c0375

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_ensure_future.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,24 @@ def tearDown(self):
5454
AsyncioInstrumentor().uninstrument()
5555

5656
@pytest.mark.asyncio
57-
def test_asyncio_loop_ensure_future(self):
57+
async def test_asyncio_loop_ensure_future(self):
5858
"""
5959
async_func is not traced because it is not set in the environment variable
6060
"""
61-
loop = asyncio.get_event_loop()
6261
task = asyncio.ensure_future(async_func())
63-
loop.run_until_complete(task)
62+
await task
6463

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

6867
@pytest.mark.asyncio
69-
def test_asyncio_ensure_future_with_future(self):
68+
async def test_asyncio_ensure_future_with_future(self):
7069
with self._tracer.start_as_current_span("root") as root:
71-
loop = asyncio.get_event_loop()
7270

7371
future = asyncio.Future()
7472
future.set_result(1)
7573
task = asyncio.ensure_future(future)
76-
loop.run_until_complete(task)
74+
await task
7775

7876
spans = self.memory_exporter.get_finished_spans()
7977
self.assertEqual(len(spans), 2)

0 commit comments

Comments
 (0)