'Abstract out boilerplace for setting up for an import test.'

def relative_import_test(self, create, globals_, callback):

    uncache_names = []
    for name in create:
        if (not name.endswith('.__init__')):
            uncache_names.append(name)
        else:
            uncache_names.append(name[:(- len('.__init__'))])
    with util.mock_spec(*create) as importer:
        with util.import_state(meta_path=[importer]):
            for global_ in globals_:
                with util.uncache(*uncache_names):
                    callback(global_)
