Skip to content

Commit

Permalink
Edit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hMatoba committed Jan 4, 2018
1 parent 4049cd7 commit f8ab1ce
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
Binary file added tests/images/tool1.webp
Binary file not shown.
49 changes: 46 additions & 3 deletions tests/s_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ def test_merge_chunks(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"tool1.webp",
"pil1.webp",
"pil2.webp",
"pil3.webp",
Expand All @@ -866,6 +867,12 @@ def test_merge_chunks(self):
]

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue

with open(IMAGE_DIR + filename, "rb") as f:
data = f.read()

Expand All @@ -882,6 +889,7 @@ def test_insert_exif(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"tool1.webp",
"pil1.webp",
"pil2.webp",
"pil3.webp",
Expand All @@ -897,6 +905,12 @@ def test_insert_exif(self):
}

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue

with open(IMAGE_DIR + filename, "rb") as f:
data = f.read()
exif_bytes = piexif.dump(exif_dict)
Expand All @@ -910,6 +924,7 @@ def test_remove_exif(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"tool1.webp",
"pil1.webp",
"pil2.webp",
"pil3.webp",
Expand All @@ -918,6 +933,12 @@ def test_remove_exif(self):
]

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue

with open(IMAGE_DIR + filename, "rb") as f:
data = f.read()
exif_removed = _webp.remove(data)
Expand All @@ -930,10 +951,16 @@ def test_get_exif(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"pil3.webp",
"tool1.webp",
]

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue

with open(IMAGE_DIR + filename, "rb") as f:
data = f.read()
exif_bytes = _webp.get_exif(data)
Expand All @@ -944,17 +971,23 @@ def test_load(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"pil3.webp",
"tool1.webp",
]

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue
print(piexif.load(IMAGE_DIR + filename))

def test_remove(self):
"""Can PIL open WebP that is removed exif?"""
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"tool1.webp",
"pil1.webp",
"pil2.webp",
"pil3.webp",
Expand All @@ -963,7 +996,11 @@ def test_remove(self):
]

for filename in files:
Image.open(IMAGE_DIR + filename)
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue
piexif.remove(IMAGE_DIR + filename, OUT_DIR + "rr_" + filename)
Image.open(OUT_DIR + "rr_" + filename)

Expand All @@ -972,6 +1009,7 @@ def test_insert(self):
IMAGE_DIR = "tests/images/"
OUT_DIR = "tests/images/out/"
files = [
"tool1.webp",
"pil1.webp",
"pil2.webp",
"pil3.webp",
Expand All @@ -988,6 +1026,11 @@ def test_insert(self):
exif_bytes = piexif.dump(exif_dict)

for filename in files:
try:
Image.open(IMAGE_DIR + filename)
except:
print("Pillow can't read {0}".format(filename))
continue
piexif.insert(exif_bytes, IMAGE_DIR + filename, OUT_DIR + "ii_" + filename)
Image.open(OUT_DIR + "ii_" + filename)

Expand Down

0 comments on commit f8ab1ce

Please sign in to comment.