 <p>There are libraries for testing like those in the <a href="https://docs.python.org/3/library/development.html" rel="nofollow">development-section</a> of the standard library. If you did not use such tools yet, you should start to do so - they help a lot with testing. (especially <code>unittest</code>).</p> <p>Normally Python runs programs in debug mode with <a href="https://docs.python.org/3/library/constants.html#__debug__" rel="nofollow"><code>__debug__</code></a> set to <code>True</code> (see <a href="https://docs.python.org/3/reference/simple_stmts.html#assert" rel="nofollow">docs on <code>assert</code></a>) - you can switch off debug mode by setting the command-line switches <code>-O</code> or <code>-OO</code> for optimization (see <a href="https://docs.python.org/3/using/cmdline.html#cmdoption-O" rel="nofollow">docs</a>).</p> <p>There is something about using specifically assertions in the <a href="https://wiki.python.org/moin/UsingAssertionsEffectively" rel="nofollow">Python Wiki</a></p>