Skip to content

Commit

Permalink
[SCHEMA] Very minor tune ups to the test_rule_objects test while tryi…
Browse files Browse the repository at this point in the history
…ng 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>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent 8628630 commit 9ed04a6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tools/schemacode/bidsschematools/data/tests/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def test_rule_objects(schema_obj):
if object_type in ["extensions", "suffixes"]:
# Some object types are referenced via their "value" fields in the rules
object_values = [
schema_obj["objects"][object_type][k]["value"]
for k in schema_obj["objects"][object_type].keys()
value["value"] for value in schema_obj["objects"][object_type].values()
]
else:
# But other object types are referenced via their keys
Expand All @@ -100,7 +99,7 @@ def test_rule_objects(schema_obj):

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


@pytest.mark.validate_schema
Expand Down

0 comments on commit 9ed04a6

Please sign in to comment.