Skip to content

Commit

Permalink
Update assert_png to check for magic bytes directly
Browse files Browse the repository at this point in the history
This avoids the use of imghdr which was removed in Ptyhon 3.13
  • Loading branch information
interop-scores-bot committed Feb 22, 2025
1 parent aabd606 commit 5d65e02
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions webdriver/tests/support/asserts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import imghdr
import json
from base64 import decodebytes

from webdriver import NoSuchAlertException, WebDriverException, WebElement
Expand Down Expand Up @@ -235,6 +233,5 @@ def assert_png(screenshot):
image = decodebytes(screenshot.encode())
else:
image = screenshot
mime_type = imghdr.what("", image)
assert mime_type == "png", "Expected image to be PNG, but it was {}".format(mime_type)
assert image.startswith(b'\211PNG\r\n\032\n'), "Expected image to be PNG"
return image

0 comments on commit 5d65e02

Please sign in to comment.