Updated tests for os.path.realpath

This commit is contained in:
Andrew Murray 2024-02-12 19:24:01 +11:00
parent 3c80ec0873
commit b7a5b5984b
6 changed files with 36 additions and 12 deletions

View File

@ -674,6 +674,10 @@ def test_save_all_progress() -> None:
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "PNG", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "PNG", save_all=True, progress=callback)
@ -700,7 +704,7 @@ def test_save_all_progress() -> None:
expected.append( expected.append(
{ {
"image_index": i, "image_index": i,
"image_filename": "Tests/images/apng/single_frame.png", "image_filename": "apng/single_frame.png",
"completed_frames": i + 1, "completed_frames": i + 1,
"total_frames": 7, "total_frames": 7,
} }
@ -709,7 +713,7 @@ def test_save_all_progress() -> None:
expected.append( expected.append(
{ {
"image_index": 2, "image_index": 2,
"image_filename": "Tests/images/apng/delay.png", "image_filename": "apng/delay.png",
"completed_frames": i + 3, "completed_frames": i + 3,
"total_frames": 7, "total_frames": 7,
} }

View File

@ -297,6 +297,10 @@ def test_save_all_progress():
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "GIF", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "GIF", save_all=True, progress=callback)
@ -328,7 +332,7 @@ def test_save_all_progress():
expected.append( expected.append(
{ {
"image_index": 1, "image_index": 1,
"image_filename": "Tests/images/chi.gif", "image_filename": "chi.gif",
"completed_frames": i + 2, "completed_frames": i + 2,
"total_frames": 32, "total_frames": 32,
} }

View File

@ -288,6 +288,10 @@ def test_save_all_progress():
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "MPO", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "MPO", save_all=True, progress=callback)
@ -308,9 +312,7 @@ def test_save_all_progress():
im.save(out, "MPO", save_all=True, append_images=[im2], progress=callback) im.save(out, "MPO", save_all=True, append_images=[im2], progress=callback)
expected = [] expected = []
for i, filename in enumerate( for i, filename in enumerate(["sugarshack.mpo", "frozenpond.mpo"]):
["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"]
):
for j in range(2): for j in range(2):
expected.append( expected.append(
{ {

View File

@ -177,6 +177,10 @@ def test_save_all_progress() -> None:
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"].replace("\\", "/").split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "PDF", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "PDF", save_all=True, progress=callback)
@ -197,9 +201,7 @@ def test_save_all_progress() -> None:
im.save(out, "PDF", save_all=True, append_images=[im2], progress=callback) im.save(out, "PDF", save_all=True, append_images=[im2], progress=callback)
expected = [] expected = []
for i, filename in enumerate( for i, filename in enumerate(["sugarshack.mpo", "frozenpond.mpo"]):
["Tests/images/sugarshack.mpo", "Tests/images/frozenpond.mpo"]
):
for j in range(2): for j in range(2):
expected.append( expected.append(
{ {

View File

@ -704,6 +704,12 @@ class TestFileTiff:
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"]
.replace("\\", "/")
.split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "TIFF", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "TIFF", save_all=True, progress=callback)
@ -728,7 +734,7 @@ class TestFileTiff:
expected = [ expected = [
{ {
"image_index": 0, "image_index": 0,
"image_filename": "Tests/images/hopper.tif", "image_filename": "hopper.tif",
"completed_frames": 1, "completed_frames": 1,
"total_frames": 4, "total_frames": 4,
} }
@ -737,7 +743,7 @@ class TestFileTiff:
expected.append( expected.append(
{ {
"image_index": 1, "image_index": 1,
"image_filename": "Tests/images/multipage.tiff", "image_filename": "multipage.tiff",
"completed_frames": i + 2, "completed_frames": i + 2,
"total_frames": 4, "total_frames": 4,
} }

View File

@ -131,6 +131,12 @@ class TestFileWebp:
progress = [] progress = []
def callback(state): def callback(state):
if state["image_filename"]:
state["image_filename"] = (
state["image_filename"]
.replace("\\", "/")
.split("Tests/images/")[-1]
)
progress.append(state) progress.append(state)
Image.new("RGB", (1, 1)).save(out, "WEBP", save_all=True, progress=callback) Image.new("RGB", (1, 1)).save(out, "WEBP", save_all=True, progress=callback)
@ -155,7 +161,7 @@ class TestFileWebp:
expected.append( expected.append(
{ {
"image_index": 0, "image_index": 0,
"image_filename": "Tests/images/iss634.webp", "image_filename": "iss634.webp",
"completed_frames": i + 1, "completed_frames": i + 1,
"total_frames": 43, "total_frames": 43,
} }