Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Dispose of the connection pools of the test engines #511

Merged
merged 1 commit into from
May 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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