From 179f8b963c6fb305371ee1f0068a33ab394fffec Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:08:26 -0500 Subject: [PATCH 1/8] curriculum: add actionable assertion messages to datetime checks (batch 2 of 2) Closes #104 [PARS-IDEMPOTENCY:branch:7735232b443ec6e523b9af3ea9de856b934a6d8aaf9d2db0b795306bc02b6e0b] --- checks/datetime/datetime7.py | 2 +- checks/datetime/datetime8.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/checks/datetime/datetime7.py b/checks/datetime/datetime7.py index 7ec69ca..a1fe20f 100644 --- a/checks/datetime/datetime7.py +++ b/checks/datetime/datetime7.py @@ -1,2 +1,2 @@ -assert appointment.isoformat() == "2026-05-23T14:45:00" +assert appointment.isoformat() == "2026-05-23T14:45:00", f"Expected appointment ISO format '2026-05-23T14:45:00', got '{appointment.isoformat()}'" print("datetime7 ok") diff --git a/checks/datetime/datetime8.py b/checks/datetime/datetime8.py index 450d6f6..e155cee 100644 --- a/checks/datetime/datetime8.py +++ b/checks/datetime/datetime8.py @@ -1,5 +1,5 @@ from datetime import date -assert earliest == date(2024, 1, 1) -assert latest == date(2026, 5, 23) +assert earliest == date(2024, 1, 1), f"Expected earliest date to be date(2024, 1, 1), got {earliest!r}" +assert latest == date(2026, 5, 23), f"Expected latest date to be date(2026, 5, 23), got {latest!r}" print("datetime8 ok") From 04db8a0f333caef58eedb5aefa6099b5f56de879 Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:09:17 -0500 Subject: [PATCH 2/8] curriculum: add actionable assertion messages to JSON checks (batch 2 of 2) Closes #102 [PARS-IDEMPOTENCY:branch:7f65ba09176b067305d7fa4defb410b28896d4eb6300b3c02de739e3946ba397] --- checks/json/json7.py | 4 ++-- checks/json/json8.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/checks/json/json7.py b/checks/json/json7.py index 50ee648..7b2fe66 100644 --- a/checks/json/json7.py +++ b/checks/json/json7.py @@ -1,3 +1,3 @@ -assert settings["theme"] == "dark" -assert encoded == '{"font_size": 12, "theme": "dark"}' +assert settings["theme"] == "dark", f"Expected settings['theme'] to be 'dark', got {settings.get('theme')!r}" +assert encoded == '{"font_size": 12, "theme": "dark"}', f"Expected encoded JSON string '{{\"font_size\": 12, \"theme\": \"dark\"}}', got {encoded!r}" print("json7 ok") diff --git a/checks/json/json8.py b/checks/json/json8.py index 3658462..94aa3bd 100644 --- a/checks/json/json8.py +++ b/checks/json/json8.py @@ -1,4 +1,4 @@ -assert decoded == original -assert tag_count == 2 -assert level == 3 +assert decoded == original, f"Expected decoded dict to equal original {original!r}, got {decoded!r}" +assert tag_count == 2, f"Expected tag_count to be 2, got {tag_count!r}" +assert level == 3, f"Expected level to be 3, got {level!r}" print("json8 ok") From d5f9c7f914ef2325ffe0c44b1bce2dd516512420 Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:09:39 -0500 Subject: [PATCH 3/8] curriculum: add actionable assertion message to context_managers8 check Fixes #92. [PARS-IDEMPOTENCY:branch:65833aa35d04461bf43dbbcf606978aa4c997e2594506d9edacbf22573fc23b6] --- checks/context_managers/context_managers8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checks/context_managers/context_managers8.py b/checks/context_managers/context_managers8.py index e3ca7c0..9a9b776 100644 --- a/checks/context_managers/context_managers8.py +++ b/checks/context_managers/context_managers8.py @@ -8,7 +8,7 @@ with ManagedPool(r) as res2: pass -assert r.acquired is False +assert r.acquired is False, "resource should be released after the second with-block" assert r.release_log == ["released", "released"], ( f"release_log should have two entries after two uses, got {r.release_log!r}" ) From 11709e14d76e98d2de65abd064c8d3d53752ddbe Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:10:21 -0500 Subject: [PATCH 4/8] curriculum: add actionable assertion messages to decorators checks (#89) Add actionable failure messages to bare assertions in checks/decorators/decorators10.py. [PARS-IDEMPOTENCY:branch:f2757544184cfee134c4c6eecb999a15a2f1de562f1675ac94c3209f61694e28] --- checks/decorators/decorators10.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/checks/decorators/decorators10.py b/checks/decorators/decorators10.py index 7776f7c..47c3ed9 100644 --- a/checks/decorators/decorators10.py +++ b/checks/decorators/decorators10.py @@ -1,12 +1,18 @@ -assert slow_square(4) == 16 -assert slow_square(5) == 25 +assert slow_square(4) == 16, f"slow_square(4) should return 16, got {slow_square(4)}" +assert slow_square(5) == 25, f"slow_square(5) should return 25, got {slow_square(5)}" # Second calls must hit the cache, not recompute -assert slow_square(4) == 16 -assert slow_square(5) == 25 +assert ( + slow_square(4) == 16 +), f"cached slow_square(4) call should return 16, got {slow_square(4)}" +assert ( + slow_square(5) == 25 +), f"cached slow_square(5) call should return 25, got {slow_square(5)}" assert call_count == 2, ( f"slow_square should have been called exactly 2 times (once per unique arg), " f"but call_count is {call_count}" ) assert (4,) in slow_square.cache, "cache should contain key (4,) for arg 4" -assert slow_square.cache[(4,)] == 16 +assert ( + slow_square.cache[(4,)] == 16 +), f"slow_square.cache[(4,)] should be 16, got {slow_square.cache[(4,)]}" print("decorators10 ✓") From 5cc70b838f191720d5bfaa873d45239b2b7cedc6 Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:16:02 -0500 Subject: [PATCH 5/8] curriculum: add actionable assertion messages to functions checks (batch 1 of 3) [PARS-IDEMPOTENCY:branch:b32214a80a92b01ba79ae2495ddce725363ed25f806e0a58980401b6f38656d0] --- checks/functions/functions1.py | 16 ++++++++-------- checks/functions/functions2.py | 4 ++-- checks/functions/functions3.py | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/checks/functions/functions1.py b/checks/functions/functions1.py index dca8cd3..588d121 100644 --- a/checks/functions/functions1.py +++ b/checks/functions/functions1.py @@ -1,9 +1,9 @@ -assert average(2, 4) == 3 -assert average(10, 20) == 15 -assert average(-2, -4) == -3 -assert average(-10, -20) == -15 -assert average(1.5, 2.5) == 2 -assert average(0.5, 1.5) == 1 -assert average(0, 0) == 0 -assert average(3, 4.5) == 3.75 +assert average(2, 4) == 3, f"average(2, 4) should return 3, got {average(2, 4)!r}" +assert average(10, 20) == 15, f"average(10, 20) should return 15, got {average(10, 20)!r}" +assert average(-2, -4) == -3, f"average(-2, -4) should return -3, got {average(-2, -4)!r}" +assert average(-10, -20) == -15, f"average(-10, -20) should return -15, got {average(-10, -20)!r}" +assert average(1.5, 2.5) == 2, f"average(1.5, 2.5) should return 2, got {average(1.5, 2.5)!r}" +assert average(0.5, 1.5) == 1, f"average(0.5, 1.5) should return 1, got {average(0.5, 1.5)!r}" +assert average(0, 0) == 0, f"average(0, 0) should return 0, got {average(0, 0)!r}" +assert average(3, 4.5) == 3.75, f"average(3, 4.5) should return 3.75, got {average(3, 4.5)!r}" print("functions1 ✓") diff --git a/checks/functions/functions2.py b/checks/functions/functions2.py index eb89916..fa401ff 100644 --- a/checks/functions/functions2.py +++ b/checks/functions/functions2.py @@ -1,4 +1,4 @@ assert callable(greet), "greet should be a function" -assert greet() == "hello" -assert message == "hello" +assert greet() == "hello", f"greet() should return 'hello', got {greet()!r}" +assert message == "hello", f"message should be 'hello', got {message!r}" print("functions2 ✓") diff --git a/checks/functions/functions3.py b/checks/functions/functions3.py index 03a5f96..420dd48 100644 --- a/checks/functions/functions3.py +++ b/checks/functions/functions3.py @@ -1,6 +1,6 @@ assert callable(double), "double should be a function" -assert double(3) == 6 -assert double(0) == 0 -assert double(-5) == -10 -assert double(2.5) == 5.0 +assert double(3) == 6, f"double(3) should return 6, got {double(3)!r}" +assert double(0) == 0, f"double(0) should return 0, got {double(0)!r}" +assert double(-5) == -10, f"double(-5) should return -10, got {double(-5)!r}" +assert double(2.5) == 5.0, f"double(2.5) should return 5.0, got {double(2.5)!r}" print("functions3 ✓") From cb98da15a26b5acf3f7b219893f30c77b74238c1 Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:20:18 -0500 Subject: [PATCH 6/8] curriculum: add actionable assertion messages to recursion checks (batch 2) Add expected and actual value messages to assertions in checks/recursion/recursion4.py and checks/recursion/recursion5.py. [PARS-IDEMPOTENCY:branch:0f123dc840816bab433fb165c53babb92a49398c3889ccb361820e25f16d3e89] --- checks/recursion/recursion4.py | 10 +++++----- checks/recursion/recursion5.py | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/checks/recursion/recursion4.py b/checks/recursion/recursion4.py index f3eeaff..94d56f3 100644 --- a/checks/recursion/recursion4.py +++ b/checks/recursion/recursion4.py @@ -1,6 +1,6 @@ -assert count_items([]) == 0 -assert count_items([42]) == 1 -assert count_items([1, 2, 3]) == 3 -assert count_items(["a", "b", "c", "d"]) == 4 -assert count_items(list(range(10))) == 10 +assert count_items([]) == 0, f"count_items([]) should return 0, got {count_items([])!r}" +assert count_items([42]) == 1, f"count_items([42]) should return 1, got {count_items([42])!r}" +assert count_items([1, 2, 3]) == 3, f"count_items([1, 2, 3]) should return 3, got {count_items([1, 2, 3])!r}" +assert count_items(["a", "b", "c", "d"]) == 4, f'count_items(["a", "b", "c", "d"]) should return 4, got {count_items(["a", "b", "c", "d"])!r}' +assert count_items(list(range(10))) == 10, f"count_items(list(range(10))) should return 10, got {count_items(list(range(10)))!r}" print("recursion4 ✓") diff --git a/checks/recursion/recursion5.py b/checks/recursion/recursion5.py index 7b419b8..4893090 100644 --- a/checks/recursion/recursion5.py +++ b/checks/recursion/recursion5.py @@ -1,7 +1,7 @@ -assert fibonacci(0) == 0 -assert fibonacci(1) == 1 -assert fibonacci(2) == 1 -assert fibonacci(5) == 5 -assert fibonacci(7) == 13 -assert fibonacci(10) == 55 +assert fibonacci(0) == 0, f"fibonacci(0) should return 0, got {fibonacci(0)!r}" +assert fibonacci(1) == 1, f"fibonacci(1) should return 1, got {fibonacci(1)!r}" +assert fibonacci(2) == 1, f"fibonacci(2) should return 1, got {fibonacci(2)!r}" +assert fibonacci(5) == 5, f"fibonacci(5) should return 5, got {fibonacci(5)!r}" +assert fibonacci(7) == 13, f"fibonacci(7) should return 13, got {fibonacci(7)!r}" +assert fibonacci(10) == 55, f"fibonacci(10) should return 55, got {fibonacci(10)!r}" print("recursion5 ✓") From e46bebfdc95867b53daf32b3d80ddbe314b0e2d7 Mon Sep 17 00:00:00 2001 From: Rooke Poole Date: Tue, 18 Aug 2026 16:21:56 -0500 Subject: [PATCH 7/8] curriculum: add actionable assertion messages to recursion checks (batch 1 of 4) Add explicit failure messages to all bare assertions in recursion1, recursion2, and recursion3 checks. [PARS-IDEMPOTENCY:branch:d04b46bb498f2b8b8970b9dc7a110fd9427ee0d2504df96dd15f8363d4322ef5] --- checks/recursion/recursion1.py | 8 ++++---- checks/recursion/recursion2.py | 8 ++++---- checks/recursion/recursion3.py | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/checks/recursion/recursion1.py b/checks/recursion/recursion1.py index 760dfa6..35840a0 100644 --- a/checks/recursion/recursion1.py +++ b/checks/recursion/recursion1.py @@ -1,5 +1,5 @@ -assert countdown(0) == [0] -assert countdown(1) == [1, 0] -assert countdown(3) == [3, 2, 1, 0] -assert countdown(5) == [5, 4, 3, 2, 1, 0] +assert countdown(0) == [0], f"countdown(0) should return [0], got {countdown(0)!r}" +assert countdown(1) == [1, 0], f"countdown(1) should return [1, 0], got {countdown(1)!r}" +assert countdown(3) == [3, 2, 1, 0], f"countdown(3) should return [3, 2, 1, 0], got {countdown(3)!r}" +assert countdown(5) == [5, 4, 3, 2, 1, 0], f"countdown(5) should return [5, 4, 3, 2, 1, 0], got {countdown(5)!r}" print("recursion1 ✓") diff --git a/checks/recursion/recursion2.py b/checks/recursion/recursion2.py index 6affe8f..4487b89 100644 --- a/checks/recursion/recursion2.py +++ b/checks/recursion/recursion2.py @@ -1,5 +1,5 @@ -assert factorial(0) == 1 -assert factorial(1) == 1 -assert factorial(5) == 120 -assert factorial(6) == 720 +assert factorial(0) == 1, f"factorial(0) should be 1, got {factorial(0)!r}" +assert factorial(1) == 1, f"factorial(1) should be 1, got {factorial(1)!r}" +assert factorial(5) == 120, f"factorial(5) should be 120, got {factorial(5)!r}" +assert factorial(6) == 720, f"factorial(6) should be 720, got {factorial(6)!r}" print("recursion2 ✓") diff --git a/checks/recursion/recursion3.py b/checks/recursion/recursion3.py index 01081d6..ba01970 100644 --- a/checks/recursion/recursion3.py +++ b/checks/recursion/recursion3.py @@ -1,6 +1,6 @@ -assert recursive_sum([]) == 0 -assert recursive_sum([5]) == 5 -assert recursive_sum([1, 2, 3]) == 6 -assert recursive_sum([10, 20, 30, 40]) == 100 -assert recursive_sum([-1, -2, 3]) == 0 +assert recursive_sum([]) == 0, f"recursive_sum([]) should be 0, got {recursive_sum([])!r}" +assert recursive_sum([5]) == 5, f"recursive_sum([5]) should be 5, got {recursive_sum([5])!r}" +assert recursive_sum([1, 2, 3]) == 6, f"recursive_sum([1, 2, 3]) should be 6, got {recursive_sum([1, 2, 3])!r}" +assert recursive_sum([10, 20, 30, 40]) == 100, f"recursive_sum([10, 20, 30, 40]) should be 100, got {recursive_sum([10, 20, 30, 40])!r}" +assert recursive_sum([-1, -2, 3]) == 0, f"recursive_sum([-1, -2, 3]) should be 0, got {recursive_sum([-1, -2, 3])!r}" print("recursion3 ✓") From 8f30a3b24458f23acafb990450fceeec3c08fbc4 Mon Sep 17 00:00:00 2001 From: Abhik Sarkar Date: Wed, 19 Aug 2026 17:53:38 +0530 Subject: [PATCH 8/8] fix(curriculum): keep assertion messages side-effect free --- checks/context_managers/context_managers8.py | 1 + checks/datetime/datetime7.py | 5 ++++- checks/datetime/datetime8.py | 1 + checks/decorators/decorators10.py | 9 +++++---- checks/functions/functions1.py | 17 +++++++++-------- checks/functions/functions2.py | 3 ++- checks/functions/functions3.py | 9 +++++---- checks/json/json7.py | 1 + checks/json/json8.py | 1 + checks/recursion/recursion1.py | 11 +++++++---- checks/recursion/recursion2.py | 9 +++++---- checks/recursion/recursion3.py | 13 ++++++++----- checks/recursion/recursion4.py | 15 ++++++++++----- checks/recursion/recursion5.py | 13 +++++++------ 14 files changed, 66 insertions(+), 42 deletions(-) diff --git a/checks/context_managers/context_managers8.py b/checks/context_managers/context_managers8.py index 9a9b776..b3ee242 100644 --- a/checks/context_managers/context_managers8.py +++ b/checks/context_managers/context_managers8.py @@ -1,3 +1,4 @@ +# checks/context_managers/context_managers8.py assert in_block_acquired is True, "resource should be acquired inside the with-block" assert r.acquired is False, "resource should be released after the with-block" assert r.release_log == ["released"], ( diff --git a/checks/datetime/datetime7.py b/checks/datetime/datetime7.py index a1fe20f..98c8d6b 100644 --- a/checks/datetime/datetime7.py +++ b/checks/datetime/datetime7.py @@ -1,2 +1,5 @@ -assert appointment.isoformat() == "2026-05-23T14:45:00", f"Expected appointment ISO format '2026-05-23T14:45:00', got '{appointment.isoformat()}'" +# checks/datetime/datetime7.py +assert appointment.isoformat() == "2026-05-23T14:45:00", ( + "appointment should use ISO format '2026-05-23T14:45:00'" +) print("datetime7 ok") diff --git a/checks/datetime/datetime8.py b/checks/datetime/datetime8.py index e155cee..35b221b 100644 --- a/checks/datetime/datetime8.py +++ b/checks/datetime/datetime8.py @@ -1,3 +1,4 @@ +# checks/datetime/datetime8.py from datetime import date assert earliest == date(2024, 1, 1), f"Expected earliest date to be date(2024, 1, 1), got {earliest!r}" diff --git a/checks/decorators/decorators10.py b/checks/decorators/decorators10.py index 47c3ed9..1fb7410 100644 --- a/checks/decorators/decorators10.py +++ b/checks/decorators/decorators10.py @@ -1,12 +1,13 @@ -assert slow_square(4) == 16, f"slow_square(4) should return 16, got {slow_square(4)}" -assert slow_square(5) == 25, f"slow_square(5) should return 25, got {slow_square(5)}" +# checks/decorators/decorators10.py +assert slow_square(4) == 16, "slow_square(4) should return 16" +assert slow_square(5) == 25, "slow_square(5) should return 25" # Second calls must hit the cache, not recompute assert ( slow_square(4) == 16 -), f"cached slow_square(4) call should return 16, got {slow_square(4)}" +), "cached slow_square(4) call should return 16" assert ( slow_square(5) == 25 -), f"cached slow_square(5) call should return 25, got {slow_square(5)}" +), "cached slow_square(5) call should return 25" assert call_count == 2, ( f"slow_square should have been called exactly 2 times (once per unique arg), " f"but call_count is {call_count}" diff --git a/checks/functions/functions1.py b/checks/functions/functions1.py index 588d121..b3b65ef 100644 --- a/checks/functions/functions1.py +++ b/checks/functions/functions1.py @@ -1,9 +1,10 @@ -assert average(2, 4) == 3, f"average(2, 4) should return 3, got {average(2, 4)!r}" -assert average(10, 20) == 15, f"average(10, 20) should return 15, got {average(10, 20)!r}" -assert average(-2, -4) == -3, f"average(-2, -4) should return -3, got {average(-2, -4)!r}" -assert average(-10, -20) == -15, f"average(-10, -20) should return -15, got {average(-10, -20)!r}" -assert average(1.5, 2.5) == 2, f"average(1.5, 2.5) should return 2, got {average(1.5, 2.5)!r}" -assert average(0.5, 1.5) == 1, f"average(0.5, 1.5) should return 1, got {average(0.5, 1.5)!r}" -assert average(0, 0) == 0, f"average(0, 0) should return 0, got {average(0, 0)!r}" -assert average(3, 4.5) == 3.75, f"average(3, 4.5) should return 3.75, got {average(3, 4.5)!r}" +# checks/functions/functions1.py +assert average(2, 4) == 3, "average(2, 4) should return 3" +assert average(10, 20) == 15, "average(10, 20) should return 15" +assert average(-2, -4) == -3, "average(-2, -4) should return -3" +assert average(-10, -20) == -15, "average(-10, -20) should return -15" +assert average(1.5, 2.5) == 2, "average(1.5, 2.5) should return 2" +assert average(0.5, 1.5) == 1, "average(0.5, 1.5) should return 1" +assert average(0, 0) == 0, "average(0, 0) should return 0" +assert average(3, 4.5) == 3.75, "average(3, 4.5) should return 3.75" print("functions1 ✓") diff --git a/checks/functions/functions2.py b/checks/functions/functions2.py index fa401ff..011976d 100644 --- a/checks/functions/functions2.py +++ b/checks/functions/functions2.py @@ -1,4 +1,5 @@ +# checks/functions/functions2.py assert callable(greet), "greet should be a function" -assert greet() == "hello", f"greet() should return 'hello', got {greet()!r}" +assert greet() == "hello", "greet() should return 'hello'" assert message == "hello", f"message should be 'hello', got {message!r}" print("functions2 ✓") diff --git a/checks/functions/functions3.py b/checks/functions/functions3.py index 420dd48..f4c301a 100644 --- a/checks/functions/functions3.py +++ b/checks/functions/functions3.py @@ -1,6 +1,7 @@ +# checks/functions/functions3.py assert callable(double), "double should be a function" -assert double(3) == 6, f"double(3) should return 6, got {double(3)!r}" -assert double(0) == 0, f"double(0) should return 0, got {double(0)!r}" -assert double(-5) == -10, f"double(-5) should return -10, got {double(-5)!r}" -assert double(2.5) == 5.0, f"double(2.5) should return 5.0, got {double(2.5)!r}" +assert double(3) == 6, "double(3) should return 6" +assert double(0) == 0, "double(0) should return 0" +assert double(-5) == -10, "double(-5) should return -10" +assert double(2.5) == 5.0, "double(2.5) should return 5.0" print("functions3 ✓") diff --git a/checks/json/json7.py b/checks/json/json7.py index 7b2fe66..a2ef3c2 100644 --- a/checks/json/json7.py +++ b/checks/json/json7.py @@ -1,3 +1,4 @@ +# checks/json/json7.py assert settings["theme"] == "dark", f"Expected settings['theme'] to be 'dark', got {settings.get('theme')!r}" assert encoded == '{"font_size": 12, "theme": "dark"}', f"Expected encoded JSON string '{{\"font_size\": 12, \"theme\": \"dark\"}}', got {encoded!r}" print("json7 ok") diff --git a/checks/json/json8.py b/checks/json/json8.py index 94aa3bd..5fc2129 100644 --- a/checks/json/json8.py +++ b/checks/json/json8.py @@ -1,3 +1,4 @@ +# checks/json/json8.py assert decoded == original, f"Expected decoded dict to equal original {original!r}, got {decoded!r}" assert tag_count == 2, f"Expected tag_count to be 2, got {tag_count!r}" assert level == 3, f"Expected level to be 3, got {level!r}" diff --git a/checks/recursion/recursion1.py b/checks/recursion/recursion1.py index 35840a0..49c8a4f 100644 --- a/checks/recursion/recursion1.py +++ b/checks/recursion/recursion1.py @@ -1,5 +1,8 @@ -assert countdown(0) == [0], f"countdown(0) should return [0], got {countdown(0)!r}" -assert countdown(1) == [1, 0], f"countdown(1) should return [1, 0], got {countdown(1)!r}" -assert countdown(3) == [3, 2, 1, 0], f"countdown(3) should return [3, 2, 1, 0], got {countdown(3)!r}" -assert countdown(5) == [5, 4, 3, 2, 1, 0], f"countdown(5) should return [5, 4, 3, 2, 1, 0], got {countdown(5)!r}" +# checks/recursion/recursion1.py +assert countdown(0) == [0], "countdown(0) should return [0]" +assert countdown(1) == [1, 0], "countdown(1) should return [1, 0]" +assert countdown(3) == [3, 2, 1, 0], "countdown(3) should return [3, 2, 1, 0]" +assert countdown(5) == [5, 4, 3, 2, 1, 0], ( + "countdown(5) should return [5, 4, 3, 2, 1, 0]" +) print("recursion1 ✓") diff --git a/checks/recursion/recursion2.py b/checks/recursion/recursion2.py index 4487b89..386bc34 100644 --- a/checks/recursion/recursion2.py +++ b/checks/recursion/recursion2.py @@ -1,5 +1,6 @@ -assert factorial(0) == 1, f"factorial(0) should be 1, got {factorial(0)!r}" -assert factorial(1) == 1, f"factorial(1) should be 1, got {factorial(1)!r}" -assert factorial(5) == 120, f"factorial(5) should be 120, got {factorial(5)!r}" -assert factorial(6) == 720, f"factorial(6) should be 720, got {factorial(6)!r}" +# checks/recursion/recursion2.py +assert factorial(0) == 1, "factorial(0) should be 1" +assert factorial(1) == 1, "factorial(1) should be 1" +assert factorial(5) == 120, "factorial(5) should be 120" +assert factorial(6) == 720, "factorial(6) should be 720" print("recursion2 ✓") diff --git a/checks/recursion/recursion3.py b/checks/recursion/recursion3.py index ba01970..1288d7c 100644 --- a/checks/recursion/recursion3.py +++ b/checks/recursion/recursion3.py @@ -1,6 +1,9 @@ -assert recursive_sum([]) == 0, f"recursive_sum([]) should be 0, got {recursive_sum([])!r}" -assert recursive_sum([5]) == 5, f"recursive_sum([5]) should be 5, got {recursive_sum([5])!r}" -assert recursive_sum([1, 2, 3]) == 6, f"recursive_sum([1, 2, 3]) should be 6, got {recursive_sum([1, 2, 3])!r}" -assert recursive_sum([10, 20, 30, 40]) == 100, f"recursive_sum([10, 20, 30, 40]) should be 100, got {recursive_sum([10, 20, 30, 40])!r}" -assert recursive_sum([-1, -2, 3]) == 0, f"recursive_sum([-1, -2, 3]) should be 0, got {recursive_sum([-1, -2, 3])!r}" +# checks/recursion/recursion3.py +assert recursive_sum([]) == 0, "recursive_sum([]) should be 0" +assert recursive_sum([5]) == 5, "recursive_sum([5]) should be 5" +assert recursive_sum([1, 2, 3]) == 6, "recursive_sum([1, 2, 3]) should be 6" +assert recursive_sum([10, 20, 30, 40]) == 100, ( + "recursive_sum([10, 20, 30, 40]) should be 100" +) +assert recursive_sum([-1, -2, 3]) == 0, "recursive_sum([-1, -2, 3]) should be 0" print("recursion3 ✓") diff --git a/checks/recursion/recursion4.py b/checks/recursion/recursion4.py index 94d56f3..18885da 100644 --- a/checks/recursion/recursion4.py +++ b/checks/recursion/recursion4.py @@ -1,6 +1,11 @@ -assert count_items([]) == 0, f"count_items([]) should return 0, got {count_items([])!r}" -assert count_items([42]) == 1, f"count_items([42]) should return 1, got {count_items([42])!r}" -assert count_items([1, 2, 3]) == 3, f"count_items([1, 2, 3]) should return 3, got {count_items([1, 2, 3])!r}" -assert count_items(["a", "b", "c", "d"]) == 4, f'count_items(["a", "b", "c", "d"]) should return 4, got {count_items(["a", "b", "c", "d"])!r}' -assert count_items(list(range(10))) == 10, f"count_items(list(range(10))) should return 10, got {count_items(list(range(10)))!r}" +# checks/recursion/recursion4.py +assert count_items([]) == 0, "count_items([]) should return 0" +assert count_items([42]) == 1, "count_items([42]) should return 1" +assert count_items([1, 2, 3]) == 3, "count_items([1, 2, 3]) should return 3" +assert count_items(["a", "b", "c", "d"]) == 4, ( + 'count_items(["a", "b", "c", "d"]) should return 4' +) +assert count_items(list(range(10))) == 10, ( + "count_items(list(range(10))) should return 10" +) print("recursion4 ✓") diff --git a/checks/recursion/recursion5.py b/checks/recursion/recursion5.py index 4893090..1d25edd 100644 --- a/checks/recursion/recursion5.py +++ b/checks/recursion/recursion5.py @@ -1,7 +1,8 @@ -assert fibonacci(0) == 0, f"fibonacci(0) should return 0, got {fibonacci(0)!r}" -assert fibonacci(1) == 1, f"fibonacci(1) should return 1, got {fibonacci(1)!r}" -assert fibonacci(2) == 1, f"fibonacci(2) should return 1, got {fibonacci(2)!r}" -assert fibonacci(5) == 5, f"fibonacci(5) should return 5, got {fibonacci(5)!r}" -assert fibonacci(7) == 13, f"fibonacci(7) should return 13, got {fibonacci(7)!r}" -assert fibonacci(10) == 55, f"fibonacci(10) should return 55, got {fibonacci(10)!r}" +# checks/recursion/recursion5.py +assert fibonacci(0) == 0, "fibonacci(0) should return 0" +assert fibonacci(1) == 1, "fibonacci(1) should return 1" +assert fibonacci(2) == 1, "fibonacci(2) should return 1" +assert fibonacci(5) == 5, "fibonacci(5) should return 5" +assert fibonacci(7) == 13, "fibonacci(7) should return 13" +assert fibonacci(10) == 55, "fibonacci(10) should return 55" print("recursion5 ✓")