diff --git a/checks/testing/testing10.py b/checks/testing/testing10.py index 190d471..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 -assert sum_list([-1, -2]) == -3 +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 9da9ab6..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 -assert abs(fahrenheit_to_celsius(212) - 100.0) < 1e-6 -assert abs(fahrenheit_to_celsius(-40) - (-40.0)) < 1e-6 +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 ✓")