Skip to content

Commit

Permalink
Output more explicit error messages
Browse files Browse the repository at this point in the history
When possible, TestResult.detail should be displayed in stderr since the
raised exception prevents from the report creation.
  • Loading branch information
pkeroulas committed Jan 17, 2024
1 parent 1902876 commit 8a4c1bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nmostesting/GenericTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions nmostesting/NMOSTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8a4c1bf

Please sign in to comment.