当在非测试代码中使用 assert
时,妥善添加断言信息
>>> assert 1 == 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
# BAD
assert "hello" == "world"
# GOOD
assert "hello" == "world", "Hello is not equal to world"
assert isinstance(req, Request), "req must request"