Skip to content

Commit

Permalink
Fix sqlalchemy flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesmet committed Sep 13, 2022
1 parent 9d898a8 commit d206e80
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/integration/test_sqlalchemy_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@


@pytest.fixture
def trino_connection(run_trino, request):
_, host, port = run_trino
def trino_connection(request):
host = "localhost"
port = 8080
engine = sqla.create_engine(f"trino://test@{host}:{port}/{request.param}",
connect_args={"source": "test", "max_attempts": 1})
yield engine, engine.connect()
Expand Down Expand Up @@ -102,7 +103,9 @@ def test_insert(trino_connection):
schema="test")
metadata.create_all(engine)
ins = users.insert()
conn.execute(ins, {"id": 2, "name": "wendy", "fullname": "Wendy Williams"})
result = conn.execute(ins, {"id": 2, "name": "wendy", "fullname": "Wendy Williams"})
# TODO: Can we get rid of this?
result.fetchall()
query = sqla.select(users)
result = conn.execute(query)
rows = result.fetchall()
Expand All @@ -126,11 +129,13 @@ def test_insert_multiple_statements(trino_connection):
schema="test")
metadata.create_all(engine)
ins = users.insert()
conn.execute(ins, [
result = conn.execute(ins, [
{"id": 2, "name": "wendy", "fullname": "Wendy Williams"},
{"id": 3, "name": "john", "fullname": "John Doe"},
{"id": 4, "name": "mary", "fullname": "Mary Hopkins"},
])
# TODO: Can we get rid of this?
result.fetchall()
query = sqla.select(users)
result = conn.execute(query)
rows = result.fetchall()
Expand Down

0 comments on commit d206e80

Please sign in to comment.