Skip to content

Commit 8731ff9

Browse files
committed
* Cleaning up as per comments in #2146
1 parent dafc587 commit 8731ff9

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

instrumentation/opentelemetry-instrumentation-psycopg/tests/test_psycopg_integration.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
from opentelemetry.test.test_base import TestBase
2525

2626

27-
def async_call(coro, *args, **kwargs):
28-
loop = asyncio.get_event_loop()
29-
return loop.run_until_complete(coro, *args, **kwargs)
30-
31-
3227
class MockCursor:
3328
execute = mock.MagicMock(spec=types.MethodType)
3429
execute.__name__ = "execute"
@@ -117,9 +112,7 @@ async def connect(*args, **kwargs):
117112
def cursor(self):
118113
if self.cursor_factory:
119114
cur = self.cursor_factory(self)
120-
print("Returning factory cursor", cur)
121115
return cur
122-
print("Returning MockAsyncCursor")
123116
return MockAsyncCursor()
124117

125118
def get_dsn_parameters(self): # pylint: disable=no-self-use
@@ -238,7 +231,7 @@ async def test_async_connection():
238231
async with cnx.cursor() as cursor:
239232
await cursor.execute("SELECT * FROM test")
240233

241-
async_call(test_async_connection())
234+
asyncio.run(test_async_connection())
242235
spans_list = self.memory_exporter.get_finished_spans()
243236
self.assertEqual(len(spans_list), 1)
244237
span = spans_list[0]
@@ -251,7 +244,7 @@ async def test_async_connection():
251244
# check that no spans are generated after uninstrument
252245
PsycopgInstrumentor().uninstrument()
253246

254-
async_call(test_async_connection())
247+
asyncio.run(test_async_connection())
255248

256249
spans_list = self.memory_exporter.get_finished_spans()
257250
self.assertEqual(len(spans_list), 1)
@@ -265,9 +258,7 @@ async def test_async_connection():
265258
async with acnx as cnx:
266259
await cnx.execute("SELECT * FROM test")
267260

268-
import asyncio
269-
270-
asyncio.run(test_async_connection)
261+
asyncio.run(test_async_connection())
271262

272263
spans_list = self.memory_exporter.get_finished_spans()
273264
self.assertEqual(len(spans_list), 1)

0 commit comments

Comments
 (0)