Skip to content

Commit e2dc984

Browse files
forsyth2zhangshixuan1987
authored andcommitted
Fix dir issues in comparing images (E3SM-Project#638)
1 parent 233a294 commit e2dc984

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/integration/utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,23 @@ def compare_images(
6262

6363
mismatched_images.append(image_name)
6464

65+
diff_dir_actual_png = os.path.join(
66+
diff_dir, "{}_actual.png".format(image_name)
67+
)
68+
# image_name could contain a number of subdirectories.
69+
os.makedirs(os.path.dirname(diff_dir_actual_png), exist_ok=True)
6570
shutil.copy(
6671
path_to_actual_png,
67-
os.path.join(diff_dir, "{}_actual.png".format(image_name)),
72+
diff_dir_actual_png,
73+
)
74+
diff_dir_expected_png = os.path.join(
75+
diff_dir, "{}_expected.png".format(image_name)
6876
)
77+
# image_name could contain a number of subdirectories.
78+
os.makedirs(os.path.dirname(diff_dir_expected_png), exist_ok=True)
6979
shutil.copy(
7080
path_to_expected_png,
71-
os.path.join(diff_dir, "{}_expected.png".format(image_name)),
81+
diff_dir_expected_png,
7282
)
7383
# https://stackoverflow.com/questions/41405632/draw-a-rectangle-and-a-text-in-it-using-pil
7484
draw = ImageDraw.Draw(diff)

0 commit comments

Comments
 (0)