Skip to content

Commit d206e80

Browse files
committed
Fix sqlalchemy flaky tests
1 parent 9d898a8 commit d206e80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/integration/test_sqlalchemy_integration.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616

1717
@pytest.fixture
18-
def trino_connection(run_trino, request):
19-
_, host, port = run_trino
18+
def trino_connection(request):
19+
host = "localhost"
20+
port = 8080
2021
engine = sqla.create_engine(f"trino://test@{host}:{port}/{request.param}",
2122
connect_args={"source": "test", "max_attempts": 1})
2223
yield engine, engine.connect()
@@ -102,7 +103,9 @@ def test_insert(trino_connection):
102103
schema="test")
103104
metadata.create_all(engine)
104105
ins = users.insert()
105-
conn.execute(ins, {"id": 2, "name": "wendy", "fullname": "Wendy Williams"})
106+
result = conn.execute(ins, {"id": 2, "name": "wendy", "fullname": "Wendy Williams"})
107+
# TODO: Can we get rid of this?
108+
result.fetchall()
106109
query = sqla.select(users)
107110
result = conn.execute(query)
108111
rows = result.fetchall()
@@ -126,11 +129,13 @@ def test_insert_multiple_statements(trino_connection):
126129
schema="test")
127130
metadata.create_all(engine)
128131
ins = users.insert()
129-
conn.execute(ins, [
132+
result = conn.execute(ins, [
130133
{"id": 2, "name": "wendy", "fullname": "Wendy Williams"},
131134
{"id": 3, "name": "john", "fullname": "John Doe"},
132135
{"id": 4, "name": "mary", "fullname": "Mary Hopkins"},
133136
])
137+
# TODO: Can we get rid of this?
138+
result.fetchall()
134139
query = sqla.select(users)
135140
result = conn.execute(query)
136141
rows = result.fetchall()

0 commit comments

Comments
 (0)