test_classes: Refine assert_json_success output with exception chaining.

Now a failure from assert_json_success and friends shows the full
server-side traceback from the JsonableError that caused the failure,
not just the test-side traceback for `AssertionError: 400 != 200 :
{message}`.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-12-03 20:38:08 -08:00
committed by Tim Abbott
parent 3319a192d4
commit 7143e6910d
3 changed files with 58 additions and 22 deletions

View File

@@ -392,7 +392,9 @@ class JsonErrorHandler(MiddlewareMixin):
# just return the response without logging further.
return response
elif RequestNotes.get_notes(request).error_format == "JSON" and not settings.TEST_SUITE:
response = json_response(res_type="error", msg=_("Internal server error"), status=500)
response = json_response(
res_type="error", msg=_("Internal server error"), status=500, exception=exception
)
else:
return None