def post(cond):
    """
     Add a postcondition check to the annotated method. The condition
     is passed the return value of the annotated method.
    """
    source = inspect.getsource(cond).strip()

    def inner(f):
        if enabled:
            # deal with the real function, not a wrapper
            f = getattr(f, 'wrapped_fn', f)

            def check_condition(result):
                if not cond(result):
                    raise AssertionError('Postcondition failure, %s' % source)

            # append to the rest of the postconditions attached to this method
            if not hasattr(f, 'postconditions'):
                f.postconditions = []
            f.postconditions.append(check_condition)

            return check(f)
        else:
            return f

    return inner
def post ( cond ) : source = inspect . getsource ( cond ) . strip ( ) def inner ( f ) : if enabled : f = getattr ( f , 'wrapped_fn' , f ) def check_condition ( result ) : if not cond ( result ) : raise AssertionError ( 'Postcondition failure, %s' % source ) if not hasattr ( f , 'postconditions' ) : f . postconditions = [ ] f . postconditions . append ( check_condition ) return check ( f ) else : return f return inner
Add a postcondition check to the annotated method. The condition
     is passed the return value of the annotated method.