File tree 1 file changed +4
-6
lines changed
instrumentation/opentelemetry-instrumentation-asyncio/tests
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -54,26 +54,24 @@ def tearDown(self):
54
54
AsyncioInstrumentor ().uninstrument ()
55
55
56
56
@pytest .mark .asyncio
57
- def test_asyncio_loop_ensure_future (self ):
57
+ async def test_asyncio_loop_ensure_future (self ):
58
58
"""
59
59
async_func is not traced because it is not set in the environment variable
60
60
"""
61
- loop = asyncio .get_event_loop ()
62
61
task = asyncio .ensure_future (async_func ())
63
- loop . run_until_complete ( task )
62
+ await task
64
63
65
64
spans = self .memory_exporter .get_finished_spans ()
66
65
self .assertEqual (len (spans ), 0 )
67
66
68
67
@pytest .mark .asyncio
69
- def test_asyncio_ensure_future_with_future (self ):
68
+ async def test_asyncio_ensure_future_with_future (self ):
70
69
with self ._tracer .start_as_current_span ("root" ) as root :
71
- loop = asyncio .get_event_loop ()
72
70
73
71
future = asyncio .Future ()
74
72
future .set_result (1 )
75
73
task = asyncio .ensure_future (future )
76
- loop . run_until_complete ( task )
74
+ await task
77
75
78
76
spans = self .memory_exporter .get_finished_spans ()
79
77
self .assertEqual (len (spans ), 2 )
You can’t perform that action at this time.
0 commit comments