From 4f20ea40283ecd8c0d79b5351a0eb6738284e9d6 Mon Sep 17 00:00:00 2001 From: Delan Azabani Date: Tue, 8 Apr 2025 19:19:09 +0800 Subject: Print the assertion when it fails Co-authored-by: Aria Edmonds Signed-off-by: Delan Azabani --- python/servo/devtools_tests.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'python/servo/devtools_tests.py') diff --git a/python/servo/devtools_tests.py b/python/servo/devtools_tests.py index 2a305e656a4..cd4c6374876 100644 --- a/python/servo/devtools_tests.py +++ b/python/servo/devtools_tests.py @@ -21,6 +21,7 @@ import subprocess import sys import time from threading import Thread +from typing import Optional def run_tests(script_path): @@ -100,10 +101,14 @@ def sources_test(client, base_url): def on_source_resource(data): for [resource_type, sources] in data["array"]: - # FIXME: If these assertions fail, we just see TimeoutError with no further information - assert resource_type == "source" - assert [source["url"] for source in sources] == [f"{base_url}/classic.js", f"{base_url}/test.html", "https://servo.org/js/load-table.js"] - done.set_result(True) + try: + assert resource_type == "source" + assert [source["url"] for source in sources] == [f"{base_url}/classic.js", f"{base_url}/test.html", "https://servo.org/js/load-table.js"] + done.set_result(None) + except Exception as e: + # Raising here does nothing, for some reason. + # Send the exception back so it can be raised. + done.set_result(e) client.add_event_listener( target["actor"], @@ -112,5 +117,7 @@ def sources_test(client, base_url): ) watcher.watch_resources([Resources.SOURCE]) - assert done.result(1) + result: Optional[Exception] = done.result(1) + if result: + raise result client.disconnect() -- cgit v1.2.3