Skip to content

Commit ada5d3b

Browse files
authored
flip require_generic_test_arguments_property behavior change flag (#11911)
* flip require_generic_test_arguments_property * fix deprecations functional tests * fix test_modified_state * fix retry project * changelog entry * improve changelog
1 parent 64b58ec commit ada5d3b

File tree

7 files changed

+53
-13
lines changed

7 files changed

+53
-13
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Default require_generic_test_arguments_property flag to True - The 'arguments' property will be parsed as keyword arguments to data tests, if provided
3+
time: 2025-08-11T15:03:47.369377+02:00
4+
custom:
5+
Author: michelleark
6+
Issue: "11911"

core/dbt/contracts/project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class ProjectFlags(ExtensibleDbtClassMixin):
361361
require_nested_cumulative_type_params: bool = False
362362
validate_macro_args: bool = False
363363
require_all_warnings_handled_by_warn_error: bool = False
364-
require_generic_test_arguments_property: bool = False
364+
require_generic_test_arguments_property: bool = True
365365

366366
@property
367367
def project_only_flags(self) -> Dict[str, Any]:

core/dbt/parser/generic_test_builders.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,14 @@ def extract_test_args(data_test, name=None) -> Tuple[str, Dict[str, Any]]:
233233
# Extract kwargs when they are nested under new 'arguments' property separately from 'config' if require_generic_test_arguments_property is enabled
234234
if get_flags().require_generic_test_arguments_property:
235235
arguments = test_args.pop("arguments", {})
236-
if not arguments and any(k not in ("config", "column_name") for k in test_args.keys()):
236+
if not arguments and any(
237+
k not in ("config", "column_name", "description", "name") for k in test_args.keys()
238+
):
237239
deprecations.warn(
238240
"missing-arguments-property-in-generic-test-deprecation", test_name=test_name
239241
)
240-
test_args = {**test_args, **arguments}
242+
if isinstance(arguments, dict):
243+
test_args = {**test_args, **arguments}
241244
elif "arguments" in test_args:
242245
deprecations.warn(
243246
"arguments-property-in-generic-test-deprecation",

tests/functional/defer_state/fixtures.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@
6969
- name: id
7070
data_tests:
7171
- unique:
72-
severity: error
72+
config:
73+
severity: error
7374
- not_null
7475
- name: name
7576
"""

tests/functional/deprecations/test_deprecations.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,16 @@ def test_jsonschema_validation_gating(
773773
assert len(event_catcher.caught_events) == expected_events
774774

775775

776-
class TestArgumentsPropertyInGenericTestDeprecation:
776+
class TestArgumentsPropertyInGenericTestDeprecationFalse:
777+
@pytest.fixture(scope="class")
778+
def project_config_update(self):
779+
return {
780+
"config-version": 2,
781+
"flags": {
782+
"require_generic_test_arguments_property": False,
783+
},
784+
}
785+
777786
@pytest.fixture(scope="class")
778787
def models(self):
779788
return {
@@ -790,7 +799,24 @@ def test_arguments_property_in_generic_test_deprecation(self, project):
790799
assert len(event_catcher.caught_events) == 4
791800

792801

793-
class TestArgumentsPropertyInGenericTestDeprecationBehaviorChange:
802+
class TestArgumentsPropertyInGenericTestDeprecationBehaviorChangeDefault:
803+
@pytest.fixture(scope="class")
804+
def models(self):
805+
return {
806+
"models_trivial.sql": models_trivial__model_sql,
807+
"models.yml": test_with_arguments_yaml,
808+
}
809+
810+
def test_arguments_property_in_generic_test_deprecation(self, project):
811+
event_catcher = EventCatcher(ArgumentsPropertyInGenericTestDeprecation)
812+
run_dbt(
813+
["parse", "--no-partial-parse", "--show-all-deprecations"],
814+
callbacks=[event_catcher.catch],
815+
)
816+
assert len(event_catcher.caught_events) == 0
817+
818+
819+
class TestArgumentsPropertyInGenericTestDeprecationTrue:
794820
@pytest.fixture(scope="class")
795821
def project_config_update(self):
796822
return {

tests/functional/fixtures/happy_path_project/seeds/s.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ seeds:
33
description: 'test_description'
44
data_tests:
55
- expression_is_true:
6-
expression: "b = 2"
6+
arguments:
7+
expression: "b = 2"
78
columns:
89
- name: a
910
description: a description

tests/functional/retry/fixtures.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,29 @@
1414
- name: foo
1515
data_tests:
1616
- accepted_values:
17-
values: [3]
18-
quote: false
17+
arguments:
18+
values: [3]
19+
quote: false
1920
config:
2021
severity: warn
2122
- name: second_model
2223
columns:
2324
- name: bar
2425
data_tests:
2526
- accepted_values:
26-
values: [3]
27-
quote: false
27+
arguments:
28+
values: [3]
29+
quote: false
2830
config:
2931
severity: warn
3032
- name: union_model
3133
columns:
3234
- name: sum3
3335
data_tests:
3436
- accepted_values:
35-
values: [3]
36-
quote: false
37+
arguments:
38+
values: [3]
39+
quote: false
3740
"""
3841

3942
macros__alter_timezone_sql = """

0 commit comments

Comments
 (0)