'Create a function suitable for use with self.addCleanup.
:returns: a callable that uses a closure to delete instance attributes'

def cleanup_instance(self, *names):

    def cleanup():
        for name in names:
            if hasattr(self, name):
                delattr(self, name)
    return cleanup
