From 25dd613e654bd51ffd26d55e5460e99ac347ea54 Mon Sep 17 00:00:00 2001 From: ytwei Date: Thu, 27 Aug 2026 20:25:26 +0800 Subject: [PATCH] fix(curriculum): add actionable JSON assertion messages --- checks/json/json1.py | 6 ++++-- checks/json/json2.py | 4 +++- checks/json/json3.py | 2 +- checks/json/json4.py | 4 +++- checks/json/json5.py | 2 +- checks/json/json6.py | 4 +++- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/checks/json/json1.py b/checks/json/json1.py index 389226d..cd4dd6a 100644 --- a/checks/json/json1.py +++ b/checks/json/json1.py @@ -1,3 +1,5 @@ -assert data == {"name": "Ada", "language": "Python"} -assert name == "Ada" +assert data == {"name": "Ada", "language": "Python"}, ( + f"data should contain Ada and Python, got {data!r}" +) +assert name == "Ada", f"name should be 'Ada', got {name!r}" print("json1 ok") diff --git a/checks/json/json2.py b/checks/json/json2.py index fa1d33f..7d61ca1 100644 --- a/checks/json/json2.py +++ b/checks/json/json2.py @@ -1,2 +1,4 @@ -assert text == '{"a": 1, "b": 2}' +assert text == '{"a": 1, "b": 2}', ( + "text should be '{\"a\": 1, \"b\": 2}'" +) print("json2 ok") diff --git a/checks/json/json3.py b/checks/json/json3.py index f043e1f..fa409b2 100644 --- a/checks/json/json3.py +++ b/checks/json/json3.py @@ -1,2 +1,2 @@ -assert city == "London" +assert city == "London", f"city should be 'London', got {city!r}" print("json3 ok") diff --git a/checks/json/json4.py b/checks/json/json4.py index 94cee2c..5b59392 100644 --- a/checks/json/json4.py +++ b/checks/json/json4.py @@ -1,2 +1,4 @@ -assert restored == {"ok": True, "count": 3} +assert restored == {"ok": True, "count": 3}, ( + f"restored should contain ok=True and count=3, got {restored!r}" +) print("json4 ok") diff --git a/checks/json/json5.py b/checks/json/json5.py index a3eb329..0042868 100644 --- a/checks/json/json5.py +++ b/checks/json/json5.py @@ -1,2 +1,2 @@ -assert timezone == "UTC" +assert timezone == "UTC", f"timezone should be 'UTC', got {timezone!r}" print("json5 ok") diff --git a/checks/json/json6.py b/checks/json/json6.py index 9a89fc8..104cf33 100644 --- a/checks/json/json6.py +++ b/checks/json/json6.py @@ -1,2 +1,4 @@ -assert active_names == ["Ada", "Guido"] +assert active_names == ["Ada", "Guido"], ( + f"active_names should be ['Ada', 'Guido'], got {active_names!r}" +) print("json6 ok")