From 8a4c1bf2150c4ab32310bda33ee95af4d91cd369 Mon Sep 17 00:00:00 2001 From: Patrick Keroulas Date: Wed, 29 Nov 2023 10:05:08 -0500 Subject: [PATCH] Output more explicit error messages When possible, TestResult.detail should be displayed in stderr since the raised exception prevents from the report creation. --- nmostesting/GenericTest.py | 2 +- nmostesting/NMOSTesting.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nmostesting/GenericTest.py b/nmostesting/GenericTest.py index 951eb1fa..ecb73131 100644 --- a/nmostesting/GenericTest.py +++ b/nmostesting/GenericTest.py @@ -671,7 +671,7 @@ def check_api_resource(self, test, resource, response_code, api, path): schema = self.get_schema(api, resource[1]["method"], resource[0], response.status_code) if not schema: - raise NMOSTestException(test.MANUAL("Test suite unable to locate schema")) + raise NMOSTestException(test.MANUAL(f"Test suite unable to locate schema for resource:{resource}")) return self.check_response(schema, resource[1]["method"], response) diff --git a/nmostesting/NMOSTesting.py b/nmostesting/NMOSTesting.py index b5dee403..39906492 100644 --- a/nmostesting/NMOSTesting.py +++ b/nmostesting/NMOSTesting.py @@ -49,7 +49,7 @@ from .DNS import DNS from .GenericTest import NMOSInitException from . import ControllerTest -from .TestResult import TestStates +from .TestResult import TestStates, TestResult from .TestHelper import get_default_ip from .NMOSUtils import DEFAULT_ARGS from .CRL import CRL, CRL_API @@ -632,7 +632,7 @@ def run_tests(test, endpoints, test_selection=["all"]): try: result = test_obj.run_tests(test_selection) except Exception as ex: - print(" * ERROR: {}".format(ex)) + print(" * ERROR while running {}: {}".format(test_selection, ex)) raise ex finally: core_app.config['TEST_ACTIVE'] = False @@ -970,7 +970,8 @@ def run_noninteractive_tests(args): else: exit_code = print_test_results(results, endpoints, args) except Exception as e: - print(" * ERROR: {}".format(str(e))) + print(" * ERROR raw: {}".format(e.args)) + print(" * ERROR in non-interactive tests: {}".format(str(e) if not isinstance(e.args[0], TestResult) else e.args[0].detail)) exit_code = ExitCodes.ERROR return exit_code