Skip to content

Commit c8f5362

Browse files
Add await to fetch calls in aio cursor tests
Tests were calling fetchone(), fetchmany(), fetchall() without await, producing "coroutine was never awaited" warnings and incorrect assertions (comparing coroutine objects instead of results). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 62adae3 commit c8f5362

File tree

3 files changed

+48
-48
lines changed

3 files changed

+48
-48
lines changed

tests/pyathena/aio/arrow/test_cursor.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ class TestAioArrowCursor:
1111
async def test_fetchone(self, aio_arrow_cursor):
1212
await aio_arrow_cursor.execute("SELECT * FROM one_row")
1313
assert aio_arrow_cursor.rownumber == 0
14-
assert aio_arrow_cursor.fetchone() == (1,)
14+
assert await aio_arrow_cursor.fetchone() == (1,)
1515
assert aio_arrow_cursor.rownumber == 1
16-
assert aio_arrow_cursor.fetchone() is None
16+
assert await aio_arrow_cursor.fetchone() is None
1717

1818
async def test_fetchmany(self, aio_arrow_cursor):
1919
await aio_arrow_cursor.execute("SELECT * FROM many_rows LIMIT 15")
20-
assert len(aio_arrow_cursor.fetchmany(10)) == 10
21-
assert len(aio_arrow_cursor.fetchmany(10)) == 5
20+
assert len(await aio_arrow_cursor.fetchmany(10)) == 10
21+
assert len(await aio_arrow_cursor.fetchmany(10)) == 5
2222

2323
async def test_fetchall(self, aio_arrow_cursor):
2424
await aio_arrow_cursor.execute("SELECT * FROM one_row")
25-
assert aio_arrow_cursor.fetchall() == [(1,)]
25+
assert await aio_arrow_cursor.fetchall() == [(1,)]
2626
await aio_arrow_cursor.execute("SELECT a FROM many_rows ORDER BY a")
27-
assert aio_arrow_cursor.fetchall() == [(i,) for i in range(10000)]
27+
assert await aio_arrow_cursor.fetchall() == [(i,) for i in range(10000)]
2828

2929
async def test_as_arrow(self, aio_arrow_cursor):
3030
await aio_arrow_cursor.execute("SELECT * FROM one_row")
@@ -45,11 +45,11 @@ async def test_execute_returns_self(self, aio_arrow_cursor):
4545

4646
async def test_no_result_set_raises(self, aio_arrow_cursor):
4747
with pytest.raises(ProgrammingError):
48-
aio_arrow_cursor.fetchone()
48+
await aio_arrow_cursor.fetchone()
4949
with pytest.raises(ProgrammingError):
50-
aio_arrow_cursor.fetchmany()
50+
await aio_arrow_cursor.fetchmany()
5151
with pytest.raises(ProgrammingError):
52-
aio_arrow_cursor.fetchall()
52+
await aio_arrow_cursor.fetchall()
5353
with pytest.raises(ProgrammingError):
5454
aio_arrow_cursor.as_arrow()
5555
with pytest.raises(ProgrammingError):
@@ -62,7 +62,7 @@ async def test_context_manager(self):
6262
try:
6363
async with conn.cursor() as cursor:
6464
await cursor.execute("SELECT * FROM one_row")
65-
assert cursor.fetchone() == (1,)
65+
assert await cursor.fetchone() == (1,)
6666
finally:
6767
conn.close()
6868

@@ -77,7 +77,7 @@ async def test_invalid_arraysize(self, aio_arrow_cursor):
7777

7878
async def test_description(self, aio_arrow_cursor):
7979
await aio_arrow_cursor.execute("SELECT CAST(1 AS INT) AS foobar FROM one_row")
80-
assert aio_arrow_cursor.fetchall() == [(1,)]
80+
assert await aio_arrow_cursor.fetchall() == [(1,)]
8181
assert aio_arrow_cursor.description == [("foobar", "integer", None, None, 10, 0, "UNKNOWN")]
8282

8383
async def test_description_initial(self, aio_arrow_cursor):
@@ -92,11 +92,11 @@ async def test_executemany_fetch(self, aio_arrow_cursor):
9292
"SELECT %(x)d FROM one_row", [{"x": i} for i in range(1, 2)]
9393
)
9494
with pytest.raises(ProgrammingError):
95-
aio_arrow_cursor.fetchall()
95+
await aio_arrow_cursor.fetchall()
9696
with pytest.raises(ProgrammingError):
97-
aio_arrow_cursor.fetchmany()
97+
await aio_arrow_cursor.fetchmany()
9898
with pytest.raises(ProgrammingError):
99-
aio_arrow_cursor.fetchone()
99+
await aio_arrow_cursor.fetchone()
100100
with pytest.raises(ProgrammingError):
101101
aio_arrow_cursor.as_arrow()
102102
with pytest.raises(ProgrammingError):
@@ -109,8 +109,8 @@ async def test_executemany_fetch(self, aio_arrow_cursor):
109109
)
110110
async def test_fetchone_unload(self, aio_arrow_cursor):
111111
await aio_arrow_cursor.execute("SELECT * FROM one_row")
112-
assert aio_arrow_cursor.fetchone() == (1,)
113-
assert aio_arrow_cursor.fetchone() is None
112+
assert await aio_arrow_cursor.fetchone() == (1,)
113+
assert await aio_arrow_cursor.fetchone() is None
114114

115115
@pytest.mark.parametrize(
116116
"aio_arrow_cursor",

tests/pyathena/aio/pandas/test_cursor.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ class TestAioPandasCursor:
1111
async def test_fetchone(self, aio_pandas_cursor):
1212
await aio_pandas_cursor.execute("SELECT * FROM one_row")
1313
assert aio_pandas_cursor.rownumber == 0
14-
assert aio_pandas_cursor.fetchone() == (1,)
14+
assert await aio_pandas_cursor.fetchone() == (1,)
1515
assert aio_pandas_cursor.rownumber == 1
16-
assert aio_pandas_cursor.fetchone() is None
16+
assert await aio_pandas_cursor.fetchone() is None
1717

1818
async def test_fetchmany(self, aio_pandas_cursor):
1919
await aio_pandas_cursor.execute("SELECT * FROM many_rows LIMIT 15")
20-
assert len(aio_pandas_cursor.fetchmany(10)) == 10
21-
assert len(aio_pandas_cursor.fetchmany(10)) == 5
20+
assert len(await aio_pandas_cursor.fetchmany(10)) == 10
21+
assert len(await aio_pandas_cursor.fetchmany(10)) == 5
2222

2323
async def test_fetchall(self, aio_pandas_cursor):
2424
await aio_pandas_cursor.execute("SELECT * FROM one_row")
25-
assert aio_pandas_cursor.fetchall() == [(1,)]
25+
assert await aio_pandas_cursor.fetchall() == [(1,)]
2626
await aio_pandas_cursor.execute("SELECT a FROM many_rows ORDER BY a")
27-
assert aio_pandas_cursor.fetchall() == [(i,) for i in range(10000)]
27+
assert await aio_pandas_cursor.fetchall() == [(i,) for i in range(10000)]
2828

2929
async def test_as_pandas(self, aio_pandas_cursor):
3030
await aio_pandas_cursor.execute("SELECT * FROM one_row")
@@ -39,11 +39,11 @@ async def test_execute_returns_self(self, aio_pandas_cursor):
3939

4040
async def test_no_result_set_raises(self, aio_pandas_cursor):
4141
with pytest.raises(ProgrammingError):
42-
aio_pandas_cursor.fetchone()
42+
await aio_pandas_cursor.fetchone()
4343
with pytest.raises(ProgrammingError):
44-
aio_pandas_cursor.fetchmany()
44+
await aio_pandas_cursor.fetchmany()
4545
with pytest.raises(ProgrammingError):
46-
aio_pandas_cursor.fetchall()
46+
await aio_pandas_cursor.fetchall()
4747
with pytest.raises(ProgrammingError):
4848
aio_pandas_cursor.as_pandas()
4949

@@ -54,7 +54,7 @@ async def test_context_manager(self):
5454
try:
5555
async with conn.cursor() as cursor:
5656
await cursor.execute("SELECT * FROM one_row")
57-
assert cursor.fetchone() == (1,)
57+
assert await cursor.fetchone() == (1,)
5858
finally:
5959
conn.close()
6060

@@ -69,7 +69,7 @@ async def test_invalid_arraysize(self, aio_pandas_cursor):
6969

7070
async def test_description(self, aio_pandas_cursor):
7171
await aio_pandas_cursor.execute("SELECT CAST(1 AS INT) AS foobar FROM one_row")
72-
assert aio_pandas_cursor.fetchall() == [(1,)]
72+
assert await aio_pandas_cursor.fetchall() == [(1,)]
7373
assert aio_pandas_cursor.description == [
7474
("foobar", "integer", None, None, 10, 0, "UNKNOWN")
7575
]
@@ -86,11 +86,11 @@ async def test_executemany_fetch(self, aio_pandas_cursor):
8686
"SELECT %(x)d FROM one_row", [{"x": i} for i in range(1, 2)]
8787
)
8888
with pytest.raises(ProgrammingError):
89-
aio_pandas_cursor.fetchall()
89+
await aio_pandas_cursor.fetchall()
9090
with pytest.raises(ProgrammingError):
91-
aio_pandas_cursor.fetchmany()
91+
await aio_pandas_cursor.fetchmany()
9292
with pytest.raises(ProgrammingError):
93-
aio_pandas_cursor.fetchone()
93+
await aio_pandas_cursor.fetchone()
9494
with pytest.raises(ProgrammingError):
9595
aio_pandas_cursor.as_pandas()
9696

@@ -101,8 +101,8 @@ async def test_executemany_fetch(self, aio_pandas_cursor):
101101
)
102102
async def test_fetchone_unload(self, aio_pandas_cursor):
103103
await aio_pandas_cursor.execute("SELECT * FROM one_row")
104-
assert aio_pandas_cursor.fetchone() == (1,)
105-
assert aio_pandas_cursor.fetchone() is None
104+
assert await aio_pandas_cursor.fetchone() == (1,)
105+
assert await aio_pandas_cursor.fetchone() is None
106106

107107
@pytest.mark.parametrize(
108108
"aio_pandas_cursor",

tests/pyathena/aio/polars/test_cursor.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ class TestAioPolarsCursor:
1111
async def test_fetchone(self, aio_polars_cursor):
1212
await aio_polars_cursor.execute("SELECT * FROM one_row")
1313
assert aio_polars_cursor.rownumber == 0
14-
assert aio_polars_cursor.fetchone() == (1,)
14+
assert await aio_polars_cursor.fetchone() == (1,)
1515
assert aio_polars_cursor.rownumber == 1
16-
assert aio_polars_cursor.fetchone() is None
16+
assert await aio_polars_cursor.fetchone() is None
1717

1818
async def test_fetchmany(self, aio_polars_cursor):
1919
await aio_polars_cursor.execute("SELECT * FROM many_rows LIMIT 15")
20-
assert len(aio_polars_cursor.fetchmany(10)) == 10
21-
assert len(aio_polars_cursor.fetchmany(10)) == 5
20+
assert len(await aio_polars_cursor.fetchmany(10)) == 10
21+
assert len(await aio_polars_cursor.fetchmany(10)) == 5
2222

2323
async def test_fetchall(self, aio_polars_cursor):
2424
await aio_polars_cursor.execute("SELECT * FROM one_row")
25-
assert aio_polars_cursor.fetchall() == [(1,)]
25+
assert await aio_polars_cursor.fetchall() == [(1,)]
2626
await aio_polars_cursor.execute("SELECT a FROM many_rows ORDER BY a")
27-
assert aio_polars_cursor.fetchall() == [(i,) for i in range(10000)]
27+
assert await aio_polars_cursor.fetchall() == [(i,) for i in range(10000)]
2828

2929
async def test_as_polars(self, aio_polars_cursor):
3030
await aio_polars_cursor.execute("SELECT * FROM one_row")
@@ -44,11 +44,11 @@ async def test_execute_returns_self(self, aio_polars_cursor):
4444

4545
async def test_no_result_set_raises(self, aio_polars_cursor):
4646
with pytest.raises(ProgrammingError):
47-
aio_polars_cursor.fetchone()
47+
await aio_polars_cursor.fetchone()
4848
with pytest.raises(ProgrammingError):
49-
aio_polars_cursor.fetchmany()
49+
await aio_polars_cursor.fetchmany()
5050
with pytest.raises(ProgrammingError):
51-
aio_polars_cursor.fetchall()
51+
await aio_polars_cursor.fetchall()
5252
with pytest.raises(ProgrammingError):
5353
aio_polars_cursor.as_polars()
5454
with pytest.raises(ProgrammingError):
@@ -61,7 +61,7 @@ async def test_context_manager(self):
6161
try:
6262
async with conn.cursor() as cursor:
6363
await cursor.execute("SELECT * FROM one_row")
64-
assert cursor.fetchone() == (1,)
64+
assert await cursor.fetchone() == (1,)
6565
finally:
6666
conn.close()
6767

@@ -76,7 +76,7 @@ async def test_invalid_arraysize(self, aio_polars_cursor):
7676

7777
async def test_description(self, aio_polars_cursor):
7878
await aio_polars_cursor.execute("SELECT CAST(1 AS INT) AS foobar FROM one_row")
79-
assert aio_polars_cursor.fetchall() == [(1,)]
79+
assert await aio_polars_cursor.fetchall() == [(1,)]
8080
assert aio_polars_cursor.description == [
8181
("foobar", "integer", None, None, 10, 0, "UNKNOWN")
8282
]
@@ -93,11 +93,11 @@ async def test_executemany_fetch(self, aio_polars_cursor):
9393
"SELECT %(x)d FROM one_row", [{"x": i} for i in range(1, 2)]
9494
)
9595
with pytest.raises(ProgrammingError):
96-
aio_polars_cursor.fetchall()
96+
await aio_polars_cursor.fetchall()
9797
with pytest.raises(ProgrammingError):
98-
aio_polars_cursor.fetchmany()
98+
await aio_polars_cursor.fetchmany()
9999
with pytest.raises(ProgrammingError):
100-
aio_polars_cursor.fetchone()
100+
await aio_polars_cursor.fetchone()
101101
with pytest.raises(ProgrammingError):
102102
aio_polars_cursor.as_polars()
103103
with pytest.raises(ProgrammingError):
@@ -110,8 +110,8 @@ async def test_executemany_fetch(self, aio_polars_cursor):
110110
)
111111
async def test_fetchone_unload(self, aio_polars_cursor):
112112
await aio_polars_cursor.execute("SELECT * FROM one_row")
113-
assert aio_polars_cursor.fetchone() == (1,)
114-
assert aio_polars_cursor.fetchone() is None
113+
assert await aio_polars_cursor.fetchone() == (1,)
114+
assert await aio_polars_cursor.fetchone() is None
115115

116116
@pytest.mark.parametrize(
117117
"aio_polars_cursor",

0 commit comments

Comments
 (0)