def assert_(test, obj, msg=None):
    """
    Raise an error if the test expression is not true.  The test can be a function that takes the context object.
    """
    if (callable(test) and not test(obj)) or not test:
        raise AssertionError(msg)
    return obj