Report on all faulty keys at once instead of crashing on first

This makes it a lot easier to communicate back to users what is going wrong.
This commit is contained in:
Ghostkeeper 2019-11-04 11:46:11 +01:00
parent aa5b788b59
commit c7c6389897
No known key found for this signature in database
GPG key ID: 59A4C0959592C05C

View file

@ -70,9 +70,12 @@ def test_validateOverridingDefaultValue(file_path: str):
if "overrides" not in doc:
return # No settings are being overridden. No need to check anything.
parent_settings = getInheritedSettings(doc["inherits"])
faulty_keys = set()
for key, val in doc["overrides"].items():
if key in parent_settings and "value" in parent_settings[key]:
assert "default_value" not in val, "Unnecessary default_value for {key} in {file_name}".format(key = key, file_name = file_path) # If there is a value in the parent settings, then the default_value is not effective.
if "default_value" in val:
faulty_keys.add(key)
assert not faulty_keys, "Unnecessary default_values for {faulty_keys} in {file_name}".format(faulty_keys = sorted(faulty_keys), file_name = file_path) # If there is a value in the parent settings, then the default_value is not effective.
## Get all settings and their properties from a definition we're inheriting
# from.