Skip to content

Commit d3facc4

Browse files
committed
modify test code
1 parent 55f2325 commit d3facc4

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Diff for: instrumentation/opentelemetry-instrumentation-asyncio/tests/common_test_func.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
async def async_func():
19-
await asyncio.sleep(1)
19+
await asyncio.sleep(0.1)
2020

2121

2222
async def factorial(name, number):

Diff for: instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_to_thread.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ def tearDown(self):
3434

3535
def test_to_thread(self):
3636
# to_thread is only available in Python 3.9+
37-
def multiply(x, y):
38-
return x * y
37+
if sys.version_info >= (3, 9):
38+
def multiply(x, y):
39+
return x * y
3940

40-
async def to_thread():
41-
result = await asyncio.to_thread(multiply, 2, 3)
42-
assert result == 6
41+
async def to_thread():
42+
result = await asyncio.to_thread(multiply, 2, 3)
43+
assert result == 6
44+
45+
asyncio.run(to_thread())
46+
spans = self.memory_exporter.get_finished_spans()
4347

44-
asyncio.run(to_thread())
45-
spans = self.memory_exporter.get_finished_spans()
46-
if sys.version_info >= (3, 9):
4748
self.assertEqual(len(spans), 1)
4849
assert spans[0].name == "asyncio.to_thread_func-multiply"

0 commit comments

Comments
 (0)