def assert_memoised_call(memoiser, function, expected, args=None, kw=None, memoised=True):
    'Assert *function* call via *memoiser* was *memoised*.'
    mapping = {'called': False}
    if (args is not None):
        args = ((mapping,) + args)
    else:
        args = (mapping,)
    result = memoiser.call(function, args, kw)
    assert (result == expected)
    assert (mapping['called'] is not memoised)
Assert *function* call via *memoiser* was *memoised*.
def assert_memoised_call(memoiser, function, expected, args=None, kw=None, memoised=True):
    
    mapping = {'called': False}
    if (args is not None):
        args = ((mapping,) + args)
    else:
        args = (mapping,)
    result = memoiser.call(function, args, kw)
    assert (result == expected)
    assert (mapping['called'] is not memoised)