Assert the specific thing.assert result passes for 1, "x", [0] and True. assert result == 7 says what you meant.
The test's job is to fail when behavior changes. An assertion loose enough to pass under several behaviors does not do that job.
◈ Graded Challenge
Write check(actual, expected) modeling a strict assertion. Return "pass" when the two are equal AND of the same broad type, and a description otherwise. Numbers and strings are different types even when they look alike, so 7 and "7" must not pass. Booleans are not numbers, so True and 1 must not pass. When they differ, return "expected X got Y" using the repr-style forms given below.
Name it exactly: check(actual, expected)
3 visible + 4 hidden
loading editor…
Mark this lesson complete
Signed in, your progress follows you to every device.