'This temporarily sets this configuration\'s value to data
(or, if present=False, to the default value).  This
returns a lambda which should be executed
when the testing phase is done.
Note that self is a new object at every access,
but self.bind_to is shared, so we can modify that.'

def set_for_testing(self, data=None, present=True):

    def set_data_presence(data, presence):
        self.bind_to[self.grab_key] = data
        if (not presence):
            del self.bind_to[self.grab_key]
    assert (self.grab_key is not _ANONYMOUS)
    old_data = self.bind_to.get(self.grab_key)
    old_presence = (self.grab_key in self.bind_to)
    set_data_presence(data, present)
    return (lambda : set_data_presence(old_data, old_presence))
