stub out instances_path in unit tests

3 unit tests were trying to write to instance_path without redirecting
it to a temporary location, which leaks directories into your working
directory.

This sets that when needed.

Change-Id: I115210163147a41e88ba43c4df100465b5159066
This commit is contained in:
Sean Dague 2016-09-19 12:41:32 -04:00
parent d4b35152c0
commit dc4d1a63ee
2 changed files with 2 additions and 0 deletions

View File

@ -16275,6 +16275,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
mock_build_device_metadata, mock_set_host_enabled,
mock_write_to_file,
exists=None):
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
mock_build_device_metadata.return_value = None
mock_supports_direct_io.return_value = True

View File

@ -1684,6 +1684,7 @@ class BackendTestCase(test.NoDBTestCase):
def setUp(self):
super(BackendTestCase, self).setUp()
self.flags(enabled=False, group='ephemeral_storage_encryption')
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
self.INSTANCE['ephemeral_key_uuid'] = None
def get_image(self, use_cow, image_type):