Skip to content

Commit

Permalink
test(duckdb): fix extension loading tests to support parallel execution
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrist authored and cpcloud committed Sep 8, 2023
1 parent 8ae2f03 commit e9f9155
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions ibis/backends/duckdb/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@
from ibis.conftest import LINUX, SANDBOXED


@pytest.fixture(scope="session")
def ext_directory(tmpdir_factory):
# A session-scoped temp directory to cache extension downloads per session.
# Coupled with the xdist_group below, this ensures that the extension
# loading tests always run in the same process and a common temporary
# directory isolated from other duckdb tests, avoiding issues with
# downloading extensions in parallel.
return str(tmpdir_factory.mktemp("exts"))


@pytest.mark.xfail(
LINUX and SANDBOXED,
reason="nix on linux cannot download duckdb extensions or data due to sandboxing",
raises=sa.exc.OperationalError,
)
def test_connect_extensions():
con = ibis.duckdb.connect(extensions=["s3", "sqlite"])
@pytest.mark.xdist_group(name="duckdb-extensions")
def test_connect_extensions(ext_directory):
con = ibis.duckdb.connect(
extensions=["s3", "sqlite"],
extension_directory=ext_directory,
)
results = con.raw_sql(
"""
SELECT loaded FROM duckdb_extensions()
Expand All @@ -29,8 +43,9 @@ def test_connect_extensions():
reason="nix on linux cannot download duckdb extensions or data due to sandboxing",
raises=duckdb.IOException,
)
def test_load_extension():
con = ibis.duckdb.connect()
@pytest.mark.xdist_group(name="duckdb-extensions")
def test_load_extension(ext_directory):
con = ibis.duckdb.connect(extension_directory=ext_directory)
con.load_extension("s3")
con.load_extension("sqlite")
results = con.raw_sql(
Expand Down

0 comments on commit e9f9155

Please sign in to comment.