Fix TestImageService's unit tests
The test class had hardcoded DEFAULT_IMAGE_DIR value to /img/ which resulted in unit tests failures when this path existed because the tests expect a call to makedirs which didn't happen as the DEFAULT_IMAGE_DIR already existed. The patch fixes that by passing exist_ok=True to makedirs call which will result in always calling makedirs, whether img_dir exists or not. Change-Id: I47d15747536394006f6b502b3025220a5077e547
This commit is contained in:
parent
9586241409
commit
6bb29fdd27
@ -128,11 +128,8 @@ class ImageService(VersionedService):
|
||||
name = image_path[image_path.rfind('/') + 1:]
|
||||
if self.convert and name[-4:] == ".img":
|
||||
name = name[:-4] + ".raw"
|
||||
if not os.path.exists(img_dir):
|
||||
try:
|
||||
os.makedirs(img_dir)
|
||||
except OSError:
|
||||
raise
|
||||
# create img_dir if it doesn't exist already
|
||||
os.makedirs(img_dir, exist_ok=True)
|
||||
alt_name = name + "_alt"
|
||||
image_id = None
|
||||
if conf.has_option('compute', 'image_ref'):
|
||||
|
Loading…
x
Reference in New Issue
Block a user