Skip to content

Commit

Permalink
Handle dbt flags based on version (#52)
Browse files Browse the repository at this point in the history
* Handle dbt flags based on version

See dbt-labs/dbt-core#9183

* Add change log entry
  • Loading branch information
JCZuurmond authored Jun 2, 2024
1 parent a843242 commit 96551ca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- Test dbt v1.7 ([PR](https://github.com/godatadriven/pytest-dbt-core/pull/48))
- Make pytest `parser.addoption` type a function ([PR](https://github.com/godatadriven/pytest-dbt-core/pull/51))
- Handle dbt flags for dbt version 1.6 and higher

## [0.2.3] - 2023-08-25

Expand Down
14 changes: 12 additions & 2 deletions src/pytest_dbt_core/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import dbt.tracking
import pytest
from _pytest.fixtures import SubRequest
from dbt import flags
from dbt import flags, version
from dbt.clients.jinja import MacroGenerator
from dbt.config import project
from dbt.config.runtime import RuntimeConfig
from dbt.context import providers
from dbt.contracts.graph.manifest import Manifest
from dbt.parser.manifest import ManifestLoader
from dbt.semver import VersionSpecifier
from dbt.tracking import User

from dbt.adapters.factory import ( # isort:skip
Expand Down Expand Up @@ -71,7 +73,15 @@ def config(request: SubRequest) -> RuntimeConfig:
profile=None,
threads=None,
)
flags.set_from_args(args, user_config=None)

if VersionSpecifier("1", "5", "12") < version.get_installed_version():
# See https://github.com/dbt-labs/dbt-core/issues/9183
project_flags = project.read_project_flags(
args.project_dir, args.profiles_dir
)
flags.set_from_args(args, project_flags)
else:
flags.set_from_args(args, user_config=None)

config = RuntimeConfig.from_args(args)
return config
Expand Down

0 comments on commit 96551ca

Please sign in to comment.