From 55ab835f3f9f5928054847b6557b711cb2bc8f57 Mon Sep 17 00:00:00 2001 From: Cor Zuurmond Date: Sun, 2 Jun 2024 12:52:01 +0200 Subject: [PATCH] Register adapter for dbt version 1.8.0 and later --- src/pytest_dbt_core/fixtures.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pytest_dbt_core/fixtures.py b/src/pytest_dbt_core/fixtures.py index bfff13f..ce0dd09 100644 --- a/src/pytest_dbt_core/fixtures.py +++ b/src/pytest_dbt_core/fixtures.py @@ -40,6 +40,10 @@ import dbt.semver as semver +if semver.VersionSpecifier("1", "7", "16") < DBT_INSTALLED_VERSION: + from dbt.mp_context import get_mp_context + + dbt.tracking.active_user = User(os.getcwd()) @@ -117,7 +121,10 @@ def adapter(config: RuntimeConfig) -> AdapterContainer: AdapterContainer The adapter. """ - register_adapter(config) + if semver.VersionSpecifier("1", "7", "16") < DBT_INSTALLED_VERSION: + register_adapter(config, get_mp_context()) + else: + register_adapter(config) adapter = get_adapter(config) adapter.acquire_connection() return adapter