'Make sure that verifyReturnTo is calling the trustroot
function verifyReturnTo'

def test_returnToVerified_callsVerify(self):

    def withVerifyReturnTo(new_verify, callable):
        old_verify = server.verifyReturnTo
        try:
            server.verifyReturnTo = new_verify
            return callable()
        finally:
            server.verifyReturnTo = old_verify
    sentinel = Exception()
    def vrfyExc(trust_root, return_to):
        self.failUnlessEqual(self.request.trust_root, trust_root)
        self.failUnlessEqual(self.request.return_to, return_to)
        raise sentinel
    try:
        withVerifyReturnTo(vrfyExc, self.request.returnToVerified)
    except Exception as e:
        self.failUnless((e is sentinel), e)
    def constVerify(val):
        def verify(trust_root, return_to):
            self.failUnlessEqual(self.request.trust_root, trust_root)
            self.failUnlessEqual(self.request.return_to, return_to)
            return val
        return verify
    for val in [True, False]:
        self.failUnlessEqual(val, withVerifyReturnTo(constVerify(val), self.request.returnToVerified))
