assert and plain test functions

assert condition, message does nothing when the condition is true. When it is false, it raises AssertionError with your message.

A test is just a function that calls your code and asserts on the result. Name it test_something, and a test runner can find it by name. This site's Check button works this way: it imports test_main.py and calls every test_ function. Its eq(got, want) helper is an assert with a clear message.

One surprise: assert is for tests and "this can't happen" checks, not for validating user input. Running python -O strips every assert out.

Another classic bug: assert (x == 1, "msg") with parentheses is a tuple, and a non-empty tuple is always true, so it never fails.

Run it. Then break slugify (drop the .lower()) and run again to see a test fail.