diff --git a/checks/context_managers/context_managers8.py b/checks/context_managers/context_managers8.py index e3ca7c0..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"], ( @@ -8,7 +9,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}" ) diff --git a/checks/datetime/datetime7.py b/checks/datetime/datetime7.py index 7ec69ca..98c8d6b 100644 --- a/checks/datetime/datetime7.py +++ b/checks/datetime/datetime7.py @@ -1,2 +1,5 @@ -assert appointment.isoformat() == "2026-05-23T14:45:00" +# 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 450d6f6..35b221b 100644 --- a/checks/datetime/datetime8.py +++ b/checks/datetime/datetime8.py @@ -1,5 +1,6 @@ +# checks/datetime/datetime8.py 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") diff --git a/checks/decorators/decorators10.py b/checks/decorators/decorators10.py index 7776f7c..1fb7410 100644 --- a/checks/decorators/decorators10.py +++ b/checks/decorators/decorators10.py @@ -1,12 +1,19 @@ -assert slow_square(4) == 16 -assert slow_square(5) == 25 +# 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 -assert slow_square(5) == 25 +assert ( + slow_square(4) == 16 +), "cached slow_square(4) call should return 16" +assert ( + slow_square(5) == 25 +), "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}" ) 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 ✓") diff --git a/checks/functions/functions1.py b/checks/functions/functions1.py index dca8cd3..b3b65ef 100644 --- a/checks/functions/functions1.py +++ b/checks/functions/functions1.py @@ -1,9 +1,10 @@ -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 +# 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 eb89916..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" -assert message == "hello" +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 03a5f96..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 -assert double(0) == 0 -assert double(-5) == -10 -assert double(2.5) == 5.0 +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 50ee648..a2ef3c2 100644 --- a/checks/json/json7.py +++ b/checks/json/json7.py @@ -1,3 +1,4 @@ -assert settings["theme"] == "dark" -assert encoded == '{"font_size": 12, "theme": "dark"}' +# 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 3658462..5fc2129 100644 --- a/checks/json/json8.py +++ b/checks/json/json8.py @@ -1,4 +1,5 @@ -assert decoded == original -assert tag_count == 2 -assert level == 3 +# 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}" print("json8 ok") diff --git a/checks/recursion/recursion1.py b/checks/recursion/recursion1.py index 760dfa6..49c8a4f 100644 --- a/checks/recursion/recursion1.py +++ b/checks/recursion/recursion1.py @@ -1,5 +1,8 @@ -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] +# 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 6affe8f..386bc34 100644 --- a/checks/recursion/recursion2.py +++ b/checks/recursion/recursion2.py @@ -1,5 +1,6 @@ -assert factorial(0) == 1 -assert factorial(1) == 1 -assert factorial(5) == 120 -assert factorial(6) == 720 +# 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 01081d6..1288d7c 100644 --- a/checks/recursion/recursion3.py +++ b/checks/recursion/recursion3.py @@ -1,6 +1,9 @@ -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 +# 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 f3eeaff..18885da 100644 --- a/checks/recursion/recursion4.py +++ b/checks/recursion/recursion4.py @@ -1,6 +1,11 @@ -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 +# 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 7b419b8..1d25edd 100644 --- a/checks/recursion/recursion5.py +++ b/checks/recursion/recursion5.py @@ -1,7 +1,8 @@ -assert fibonacci(0) == 0 -assert fibonacci(1) == 1 -assert fibonacci(2) == 1 -assert fibonacci(5) == 5 -assert fibonacci(7) == 13 -assert fibonacci(10) == 55 +# 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 ✓")