From 02e5a7cfbb1ce03c16aafe79da8bb579d66b303f Mon Sep 17 00:00:00 2001 From: mercael Date: Sat, 10 Oct 2026 05:55:41 +0300 Subject: [PATCH 1/3] curriculum: add actionable assertion messages to testing checks Signed-off-by: mercael --- checks/testing/testing8.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checks/testing/testing8.py b/checks/testing/testing8.py index 9da9ab6..9180e20 100644 --- a/checks/testing/testing8.py +++ b/checks/testing/testing8.py @@ -21,7 +21,7 @@ def _code(fn): assert len(cases) >= 3, "cases should hold at least 3 (input, expected) pairs" # run a direct spot check -assert abs(fahrenheit_to_celsius(32) - 0.0) < 1e-6 -assert abs(fahrenheit_to_celsius(212) - 100.0) < 1e-6 -assert abs(fahrenheit_to_celsius(-40) - (-40.0)) < 1e-6 +assert abs(fahrenheit_to_celsius(32) - 0.0) < 1e-6, "fahrenheit_to_celsius(32) should be 0.0, got %r" % fahrenheit_to_celsius(32) +assert abs(fahrenheit_to_celsius(212) - 100.0) < 1e-6, "fahrenheit_to_celsius(212) should be 100.0, got %r" % fahrenheit_to_celsius(212) +assert abs(fahrenheit_to_celsius(-40) - (-40.0)) < 1e-6, "fahrenheit_to_celsius(-40) should be -40.0, got %r" % fahrenheit_to_celsius(-40) print("testing8 ✓") From 14839756ff1ef5bc57c91c2d9273ebb540aa5550 Mon Sep 17 00:00:00 2001 From: mercael Date: Sat, 10 Oct 2026 05:55:42 +0300 Subject: [PATCH 2/3] curriculum: add actionable assertion messages to testing checks Signed-off-by: mercael --- checks/testing/testing10.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checks/testing/testing10.py b/checks/testing/testing10.py index 190d471..6fd2d1a 100644 --- a/checks/testing/testing10.py +++ b/checks/testing/testing10.py @@ -4,6 +4,6 @@ src = inspect.getsource(test_sum_list) assert src.count("assert") >= 5, "test_sum_list should contain at least 5 assertions" # spot-check the empty-list edge case -assert sum_list([]) == 0 -assert sum_list([-1, -2]) == -3 +assert sum_list([]) == 0, "sum_list([]) should be 0, got %r" % sum_list([]) +assert sum_list([-1, -2]) == -3, "sum_list([-1, -2]) should be -3, got %r" % sum_list([-1, -2]) print("testing10 ✓") From cb3e2bcb892418f9b498368992188e0b38f91dc3 Mon Sep 17 00:00:00 2001 From: mercael Date: Sat, 10 Oct 2026 06:36:20 +0300 Subject: [PATCH 3/3] curriculum: keep the testing check messages on the learner's value Both files reported the actual value by calling the learner function again inside the message. CONTRIBUTING.md asks for the actual value where it is cheap but never a re-call, so the call is bound once and the message reads that binding instead. The three long lines are also wrapped to stay inside the 80-column limit. --- checks/testing/testing10.py | 8 ++++++-- checks/testing/testing8.py | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/checks/testing/testing10.py b/checks/testing/testing10.py index 6fd2d1a..df37d68 100644 --- a/checks/testing/testing10.py +++ b/checks/testing/testing10.py @@ -4,6 +4,10 @@ src = inspect.getsource(test_sum_list) assert src.count("assert") >= 5, "test_sum_list should contain at least 5 assertions" # spot-check the empty-list edge case -assert sum_list([]) == 0, "sum_list([]) should be 0, got %r" % sum_list([]) -assert sum_list([-1, -2]) == -3, "sum_list([-1, -2]) should be -3, got %r" % sum_list([-1, -2]) +empty_sum = sum_list([]) +assert empty_sum == 0, "sum_list([]) should be 0, got %r" % empty_sum +negative_sum = sum_list([-1, -2]) +assert negative_sum == -3, ( + "sum_list([-1, -2]) should be -3, got %r" % negative_sum +) print("testing10 ✓") diff --git a/checks/testing/testing8.py b/checks/testing/testing8.py index 9180e20..0070883 100644 --- a/checks/testing/testing8.py +++ b/checks/testing/testing8.py @@ -21,7 +21,16 @@ def _code(fn): assert len(cases) >= 3, "cases should hold at least 3 (input, expected) pairs" # run a direct spot check -assert abs(fahrenheit_to_celsius(32) - 0.0) < 1e-6, "fahrenheit_to_celsius(32) should be 0.0, got %r" % fahrenheit_to_celsius(32) -assert abs(fahrenheit_to_celsius(212) - 100.0) < 1e-6, "fahrenheit_to_celsius(212) should be 100.0, got %r" % fahrenheit_to_celsius(212) -assert abs(fahrenheit_to_celsius(-40) - (-40.0)) < 1e-6, "fahrenheit_to_celsius(-40) should be -40.0, got %r" % fahrenheit_to_celsius(-40) +celsius_32 = fahrenheit_to_celsius(32) +assert abs(celsius_32 - 0.0) < 1e-6, ( + "fahrenheit_to_celsius(32) should be 0.0, got %r" % celsius_32 +) +celsius_212 = fahrenheit_to_celsius(212) +assert abs(celsius_212 - 100.0) < 1e-6, ( + "fahrenheit_to_celsius(212) should be 100.0, got %r" % celsius_212 +) +celsius_minus40 = fahrenheit_to_celsius(-40) +assert abs(celsius_minus40 - (-40.0)) < 1e-6, ( + "fahrenheit_to_celsius(-40) should be -40.0, got %r" % celsius_minus40 +) print("testing8 ✓")