The assert statement provides a way to verify the internal state of your code. To the assertion, you provide a conditional expression that is expected to evaluate true.
If the verification fails (condition is false), an exception (AssertException) is raised.

The exception reports the source code of the condition, the file name, the line number, the current object and information provided as an optional second argument to the assert. However, it's rarely necessary to provide a second, informational argument because a failed assertion also reports the value of every subexpression of the condition.

For example assert < bar failing its assertion will report the value of, obj and bar. This makes assertions quick to write and easy to diagnose.

See  assert in Cobra Reference Docs.


assert <condition> [, info]



assert i > 0

assert < bar

assert not badValue   # test that a boolean value is false

assert obj   # assert obj not null
assert name.length # assert name is not 0 length  

assert 'result=' in resultString 

# assert with explicit info message
assert _didReset, 'Have not reset. Probably subclass overrides _reset but did not invoke base.'