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

Fix flaky attach test #386

Merged
merged 3 commits into from
Apr 23, 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
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
Loading