Skip to content

Commit 9ed04a6

Browse files
yarikopticeffigiespre-commit-ci[bot]
authored
[SCHEMA] Very minor tune ups to the test_rule_objects test while trying to grasp its function (#1728)
* RF: minor simplification of Python code If the point is to go through values, just go through .values() without iterating through keys() and then dereferencing via [key] * Raise AssertionError in the test, not ValueError Since then also it is not clear if that is indeed some ValueError from within code. I also added a string which summarizes the problem. * Update tools/schemacode/bidsschematools/data/tests/test_rules.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Chris Markiewicz <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 8628630 commit 9ed04a6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tools/schemacode/bidsschematools/data/tests/test_rules.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ def test_rule_objects(schema_obj):
8383
if object_type in ["extensions", "suffixes"]:
8484
# Some object types are referenced via their "value" fields in the rules
8585
object_values = [
86-
schema_obj["objects"][object_type][k]["value"]
87-
for k in schema_obj["objects"][object_type].keys()
86+
value["value"] for value in schema_obj["objects"][object_type].values()
8887
]
8988
else:
9089
# But other object types are referenced via their keys
@@ -100,7 +99,7 @@ def test_rule_objects(schema_obj):
10099

101100
if not_found:
102101
not_found_string = "\n".join([f"{'.'.join(path)} == {val}" for path, val in not_found])
103-
raise ValueError(not_found_string)
102+
raise AssertionError(f"Undefined objects found in rules: {not_found_string}")
104103

105104

106105
@pytest.mark.validate_schema

0 commit comments

Comments
 (0)