Skip to content

Commit

Permalink
Merge pull request #386 from duckdb/jwills_fix_flaky_attach_test
Browse files Browse the repository at this point in the history
Fix flaky attach test
  • Loading branch information
jwills authored Apr 23, 2024
2 parents 6044694 + 3a9a74a commit 175ce0c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions tests/functional/adapter/test_attach.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import tempfile

import duckdb
import pytest
Expand Down Expand Up @@ -32,17 +33,17 @@
"""


@pytest.mark.skip_profile("buenavista", "md")
@pytest.mark.skip_profile("memory", "buenavista", "md")
class TestAttachedDatabase:
@pytest.fixture(scope="class")
def attach_test_db(self):
path = "/tmp/attach_test.duckdb"
db = duckdb.connect(path)
db.execute("CREATE SCHEMA analytics")
db.execute("CREATE TABLE analytics.attached_table AS SELECT 1 as id")
db.close()
yield path
os.unlink(path)
with tempfile.TemporaryDirectory() as temp_dir:
path = os.path.join(temp_dir, "attach_test.duckdb")
db = duckdb.connect(path)
db.execute("CREATE SCHEMA analytics")
db.execute("CREATE TABLE analytics.attached_table AS SELECT 1 as id")
db.close()
yield path

@pytest.fixture(scope="class")
def profiles_config_update(self, dbt_profile_target, attach_test_db):
Expand Down Expand Up @@ -78,6 +79,7 @@ def test_attached_databases(self, project, attach_test_db):
db = duckdb.connect(attach_test_db)
ret = db.execute("SELECT * FROM target_model").fetchall()
assert ret[0][0] == 1
db.close()

# check that everything works on a re-run of dbt
rerun_results = run_dbt()
Expand Down

0 comments on commit 175ce0c

Please sign in to comment.