'Tests that we exit early from mutated_migration_context if the
migration_context attribute is set to None meaning this instance is
not being migrated.'

@mock.patch('nova.objects.Instance.obj_load_attr', new_callable=mock.NonCallableMock)
def test_mutated_migration_context_early_exit(self, obj_load_attr):

    inst = instance.Instance(context=self.context, migration_context=None)
    for attr in instance._MIGRATION_CONTEXT_ATTRS:
        self.assertNotIn(attr, inst)
    with inst.mutated_migration_context():
        for attr in instance._MIGRATION_CONTEXT_ATTRS:
            self.assertNotIn(attr, inst)
