Skip to content

Commit

Permalink
Test: Dispose of the connection pools of the test engines (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-berchet authored May 1, 2024
1 parent e626cd9 commit 11dadb4
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,23 @@ def engine(tmpdir, db_url, _engine_echo):
# Copy the input SQLite DB to a temporary file and return an engine to it
input_url = str(db_url)[10:]
output_file = "test_spatial_db.sqlite"
return copy_and_connect_sqlite_db(input_url, tmpdir / output_file, _engine_echo, "sqlite")

if db_url.startswith("gpkg:///"):
current_engine = copy_and_connect_sqlite_db(
input_url, tmpdir / output_file, _engine_echo, "sqlite"
)
elif db_url.startswith("gpkg:///"):
# Copy the input SQLite DB to a temporary file and return an engine to it
input_url = str(db_url)[8:]
output_file = "test_spatial_db.gpkg"
return copy_and_connect_sqlite_db(input_url, tmpdir / output_file, _engine_echo, "gpkg")
current_engine = copy_and_connect_sqlite_db(
input_url, tmpdir / output_file, _engine_echo, "gpkg"
)
else:
# For other dialects the engine is directly returned
current_engine = create_engine(db_url, echo=_engine_echo)
current_engine.update_execution_options(search_path=["gis", "public"])

# For other dialects the engine is directly returned
engine = create_engine(db_url, echo=_engine_echo)
engine.update_execution_options(search_path=["gis", "public"])
return engine
yield current_engine
current_engine.dispose()


@pytest.fixture
Expand Down

0 comments on commit 11dadb4

Please sign in to comment.