Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions checks/testing/testing10.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ✓")
15 changes: 12 additions & 3 deletions checks/testing/testing8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ✓")
Loading