Skip to content

Commit

Permalink
Updated tests for os.path.realpath
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 12, 2024
1 parent 3c80ec0 commit b7a5b59
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
8 changes: 6 additions & 2 deletions Tests/test_file_apng.py
Expand Up @@ -674,6 +674,10 @@ def test_save_all_progress() -> None:
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "PNG", save_all=True, progress=callback)
Expand All @@ -700,7 +704,7 @@ def callback(state):
expected.append(
{
"image_index": i,
"image_filename": "Tests/images/apng/single_frame.png",
"image_filename": "apng/single_frame.png",
"completed_frames": i + 1,
"total_frames": 7,
}
Expand All @@ -709,7 +713,7 @@ def callback(state):
expected.append(
{
"image_index": 2,
"image_filename": "Tests/images/apng/delay.png",
"image_filename": "apng/delay.png",
"completed_frames": i + 3,
"total_frames": 7,
}
Expand Down
6 changes: 5 additions & 1 deletion Tests/test_file_gif.py
Expand Up @@ -297,6 +297,10 @@ def test_save_all_progress():
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "GIF", save_all=True, progress=callback)
Expand Down Expand Up @@ -328,7 +332,7 @@ def callback(state):
expected.append(
{
"image_index": 1,
"image_filename": "Tests/images/chi.gif",
"image_filename": "chi.gif",
"completed_frames": i + 2,
"total_frames": 32,
}
Expand Down
8 changes: 5 additions & 3 deletions Tests/test_file_mpo.py
Expand Up @@ -288,6 +288,10 @@ def test_save_all_progress():
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "MPO", save_all=True, progress=callback)
Expand All @@ -308,9 +312,7 @@ def callback(state):
im.save(out, "MPO", save_all=True, append_images=[im2], progress=callback)

expected = []
for i, filename in enumerate(
["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"]
):
for i, filename in enumerate(["sugarshack.mpo", "frozenpond.mpo"]):
for j in range(2):
expected.append(
{
Expand Down
8 changes: 5 additions & 3 deletions Tests/test_file_pdf.py
Expand Up @@ -177,6 +177,10 @@ def test_save_all_progress() -> None:
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "PDF", save_all=True, progress=callback)
Expand All @@ -197,9 +201,7 @@ def callback(state):
im.save(out, "PDF", save_all=True, append_images=[im2], progress=callback)

expected = []
for i, filename in enumerate(
["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"]
):
for i, filename in enumerate(["sugarshack.mpo", "frozenpond.mpo"]):
for j in range(2):
expected.append(
{
Expand Down
10 changes: 8 additions & 2 deletions Tests/test_file_tiff.py
Expand Up @@ -704,6 +704,12 @@ def test_save_all_progress(self) -> None:
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"]
.replace("\\", "/")
.split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "TIFF", save_all=True, progress=callback)
Expand All @@ -728,7 +734,7 @@ def callback(state):
expected = [
{
"image_index": 0,
"image_filename": "Tests/images/hopper.tif",
"image_filename": "hopper.tif",
"completed_frames": 1,
"total_frames": 4,
}
Expand All @@ -737,7 +743,7 @@ def callback(state):
expected.append(
{
"image_index": 1,
"image_filename": "Tests/images/multipage.tiff",
"image_filename": "multipage.tiff",
"completed_frames": i + 2,
"total_frames": 4,
}
Expand Down
8 changes: 7 additions & 1 deletion Tests/test_file_webp.py
Expand Up @@ -131,6 +131,12 @@ def test_save_all_progress(self) -> None:
progress = []

def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"]
.replace("\\", "/")
.split("Tests/images/")[-1]
)
progress.append(state)

Image.new("RGB", (1, 1)).save(out, "WEBP", save_all=True, progress=callback)
Expand All @@ -155,7 +161,7 @@ def callback(state):
expected.append(
{
"image_index": 0,
"image_filename": "Tests/images/iss634.webp",
"image_filename": "iss634.webp",
"completed_frames": i + 1,
"total_frames": 43,
}
Expand Down

0 comments on commit b7a5b59

Please sign in to comment.