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 11, 2025
1 parent ed4dc56 commit c0969f8
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions webdriver/tests/support/asserts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import imghdr
from base64 import decodebytes

from webdriver import NoSuchAlertException, WebDriverException, WebElement
Expand Down Expand Up @@ -227,6 +226,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

1 comment on commit c0969f8

@community-tc-integration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error!

HttpError: Invalid request.

Only 65535 characters are allowed; 6498807 were supplied.

Please sign in to comment.