

def setUp(self):
    super(TestCli, self).setUp()
    self.do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command')
    self.do_alembic_cmd = self.do_alembic_cmd_p.start()
    self.mock_alembic_err = mock.patch('alembic.util.err').start()
    self.mock_alembic_warn = mock.patch('alembic.util.warn').start()
    self.mock_alembic_err.side_effect = SystemExit

    def mocked_root_dir(cfg):
        return os.path.join('/fake/dir', cli._get_project_base(cfg))
    mock_root = mock.patch.object(cli, '_get_package_root_dir').start()
    mock_root.side_effect = mocked_root_dir
    mock.patch('neutron.common.utils.ensure_dir').start()
    self.configs = []
    self.projects = ('neutron', 'networking-foo', 'neutron-fwaas')
    ini = os.path.join(os.path.dirname(cli.__file__), 'alembic.ini')
    self.useFixture(MigrationEntrypointsMemento())
    cli.migration_entrypoints = {
        
    }
    for project in self.projects:
        config = alembic_config.Config(ini)
        config.set_main_option('neutron_project', project)
        module_name = (project.replace('-', '_') + '.db.migration')
        attrs = ('alembic_migrations',)
        script_location = ':'.join([module_name, attrs[0]])
        config.set_main_option('script_location', script_location)
        self.configs.append(config)
        entrypoint = pkg_resources.EntryPoint(project, module_name, attrs=attrs)
        cli.migration_entrypoints[project] = entrypoint

dataset/ETHPy150Open openstack/neutron/neutron/tests/unit/db/test_migration.py TestCli.setUp/original