Skip to content
Merged
3 changes: 2 additions & 1 deletion checks/context_managers/context_managers8.py
Original file line number Diff line number Diff line change
@@ -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"], (
Expand All @@ -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"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap this assertion to keep it within the Google Python style guide 80-character limit. The same issue appears in checks/datetime/datetime8.py lines 4-5, checks/json/json7.py lines 2-3, and checks/json/json8.py line 2. Preserve the predicates and message text.

assert r.release_log == ["released", "released"], (
f"release_log should have two entries after two uses, got {r.release_log!r}"
)
Expand Down
5 changes: 4 additions & 1 deletion checks/datetime/datetime7.py
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 3 additions & 2 deletions checks/datetime/datetime8.py
Original file line number Diff line number Diff line change
@@ -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")
17 changes: 12 additions & 5 deletions checks/decorators/decorators10.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
17 changes: 9 additions & 8 deletions checks/functions/functions1.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
5 changes: 3 additions & 2 deletions checks/functions/functions2.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
9 changes: 5 additions & 4 deletions checks/functions/functions3.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
5 changes: 3 additions & 2 deletions checks/json/json7.py
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 4 additions & 3 deletions checks/json/json8.py
Original file line number Diff line number Diff line change
@@ -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")
11 changes: 7 additions & 4 deletions checks/recursion/recursion1.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
9 changes: 5 additions & 4 deletions checks/recursion/recursion2.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
13 changes: 8 additions & 5 deletions checks/recursion/recursion3.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
15 changes: 10 additions & 5 deletions checks/recursion/recursion4.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
13 changes: 7 additions & 6 deletions checks/recursion/recursion5.py
Original file line number Diff line number Diff line change
@@ -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 ✓")
Loading