def assert_is_not_none(expr, msg_fmt="{msg}"):
    """Fail if the expression is None.

    >>> assert_is_not_none(0)
    >>> assert_is_not_none(None)
    Traceback (most recent call last):
        ...
    AssertionError: expression is None

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * expr - tested expression
    """
    if expr is None:
        msg = "expression is None"
        fail(msg_fmt.format(msg=msg, expr=expr))
Fail if the expression is None.

    >>> assert_is_not_none(0)
    >>> assert_is_not_none(None)
    Traceback (most recent call last):
        ...
    AssertionError: expression is None

    The following msg_fmt arguments are supported:
    * msg - the default error message
    * expr - tested expression