
28 Apr
2011
28 Apr
'11
6:59 p.m.
On Thu, Apr 28, 2011 at 12:54 AM, Tarek Ziadé ziade.tarek@gmail.com wrote:
In my opinion assert should be avoided completely anywhere else than in the tests. If this is a wrong statement, please let me know why :)
I would turn that around. The assert statement should not be used in unit tests; unit tests should use self.assertXyzzy() always. In regular code, assert should be about detecting buggy code. It should not be used to test for error conditions in input data. (Both these can be summarized as "if you still want the test to happen with -O, don't use assert.)
--
--Guido van Rossum (python.org/~guido)