'Run before each test method to initialize test environment.'

def setUp(self):

    super(TestCase, self).setUp()
    self.useFixture(nova_fixtures.Timeout(os.environ.get('OS_TEST_TIMEOUT', 0), self.TIMEOUT_SCALING_FACTOR))
    self.useFixture(fixtures.NestedTempfile())
    self.useFixture(fixtures.TempHomeDir())
    self.useFixture(log_fixture.get_logging_handle_error_fixture())
    self.useFixture(nova_fixtures.OutputStreamCapture())
    self.stdlog = nova_fixtures.StandardLogging()
    self.useFixture(self.stdlog)
    if self.REQUIRES_LOCKING:
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path, group='oslo_concurrency')
    self.useFixture(conf_fixture.ConfFixture(CONF))
    self.useFixture(nova_fixtures.RPCFixture('nova.test'))
    CONF.set_default('driver', ['test'], group='oslo_messaging_notifications')
    objects_base.NovaObject.indirection_api = None
    self._base_test_obj_backup = copy.copy(objects_base.NovaObjectRegistry._registry._obj_classes)
    self.addCleanup(self._restore_obj_registry)
    from nova.compute import api
    api.CELLS = []
    context.CELL_CACHE = {}
    context.CELLS = []
    self.cell_mappings = {}
    self.host_mappings = {}
    if self.USES_DB:
        self.useFixture(nova_fixtures.Database(database='api'))
        self._setup_cells()
        self.useFixture(nova_fixtures.DefaultFlavorsFixture())
    elif (not self.USES_DB_SELF):
        self.useFixture(nova_fixtures.SingleCellSimple())
        self.useFixture(nova_fixtures.DatabasePoisonFixture())
    self.useFixture(nova_fixtures.WarningsFixture())
    self.useFixture(ovo_fixture.StableObjectJsonFixture())
    utils._IS_NEUTRON = None
    objects.resource_provider._TRAITS_SYNCED = False
    mox_fixture = self.useFixture(moxstubout.MoxStubout())
    self.mox = mox_fixture.mox
    self.stubs = mox_fixture.stubs
    self.addCleanup(self._clear_attrs)
    self.useFixture(fixtures.EnvironmentVariable('http_proxy'))
    self.policy = self.useFixture(policy_fixture.PolicyFixture())
    self.useFixture(nova_fixtures.PoisonFunctions())
    openstack_driver.DRIVER_CACHE = {}
    self.useFixture(nova_fixtures.ForbidNewLegacyNotificationFixture())
