From 65bc29cd4c9e4d029bd726e8d2617f18451acd10 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 14 May 2019 09:08:50 +0200 Subject: [PATCH] Give slightly more information when definition is invalid Because it now fails at the assertion inside assertIsDefinitionValid, it'll show the information at that point in the stack, rather than showing that the entire function returned False which could be a lot of things (if you don't actually go reading the function because then you discovered that it could only be one thing). --- tests/Settings/TestDefinitionContainer.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/Settings/TestDefinitionContainer.py b/tests/Settings/TestDefinitionContainer.py index e4a993c26a..73d4e89d20 100644 --- a/tests/Settings/TestDefinitionContainer.py +++ b/tests/Settings/TestDefinitionContainer.py @@ -36,15 +36,14 @@ def test_validateMachineDefinitionContainer(file_name, definition_container): return # Stop checking, these are root files. definition_path = os.path.join(os.path.dirname(__file__), "..", "..", "resources", "definitions") - assert isDefinitionValid(definition_container, definition_path, file_name) + assertIsDefinitionValid(definition_container, definition_path, file_name) -def isDefinitionValid(definition_container, path, file_name): +def assertIsDefinitionValid(definition_container, path, file_name): with open(os.path.join(path, file_name), encoding = "utf-8") as data: json = data.read() parser, is_valid = definition_container.readAndValidateSerialized(json) - if not is_valid: - print("The definition '{0}', has invalid data.".format(file_name)) + assert is_valid #The definition has invalid JSON structure. metadata = DefinitionContainer.deserializeMetadata(json, "whatever") # If the definition defines a platform file, it should be in /resources/meshes/ @@ -52,6 +51,4 @@ def isDefinitionValid(definition_container, path, file_name): assert metadata[0]["platform"] in all_meshes if "platform_texture" in metadata[0]: - assert metadata[0]["platform_texture"] in all_images - - return is_valid + assert metadata[0]["platform_texture"] in all_images \ No newline at end of file