I am writing tests and I have heard some people saying to use self.assertFalse
rather than assert False
. Why is this and are there any advantages to be had?
assert False
throws an exception without useful logging information. The test had an error.
self.assertFalse()
throws a test failure exception with test failure information like a message and a test name.
There's a difference between an error -- test could not even run -- and a failure -- test code worked but produced the wrong answer.
Errors are a serious problem with your code.
Failures are just failures that need to be fixed.