Quantcast
Channel: Best practice for using assert? - Stack Overflow
Viewing all articles
Browse latest Browse all 17

Answer by Emilio M Bumachar for Best practice for using assert?

$
0
0

For what it's worth, if you're dealing with code which relies on assert to function properly, then adding the following code will ensure that asserts are enabled:

try:    assert False    raise Exception('Python assertions are not working. This tool relies on Python assertions to do its job. Possible causes are running with the "-O" flag or running a precompiled (".pyo" or ".pyc") module.')except AssertionError:    pass

Viewing all articles
Browse latest Browse all 17

Trending Articles