Skip to content

Commit a856395

Browse files
yoffRasmusWL
andauthored
Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
1 parent aa1541a commit a856395

File tree

1 file changed

+9
-2
lines changed
  • python/ql/test/library-tests/frameworks/aiopg

1 file changed

+9
-2
lines changed

python/ql/test/library-tests/frameworks/aiopg/test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,20 @@ async def test_cursor():
1111
async with aiopg.create_pool() as pool:
1212
# Create Cursor via Connection
1313
async with pool.acquire() as conn:
14-
cur = await conn.cursor()
15-
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
14+
async with conn.cursor() as cur:
15+
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
1616

1717
# Create Cursor directly
1818
async with pool.cursor() as cur:
1919
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
2020

21+
# variants using as few `async with` as possible
22+
pool = await aiopg.create_pool()
23+
conn = pool.acquire()
24+
cur = await conn.cursor()
25+
await cur.execute("sql") # $ getSql="sql" constructedSql="sql"
26+
27+
# Test SQLAlchemy integration
2128
from aiopg.sa import create_engine
2229

2330
async def test_engine():

0 commit comments

Comments
 (0)