From f00a6e18a80188d0c0357924c6bffaaf1afb9f61 Mon Sep 17 00:00:00 2001 From: Thiago Perrotta Date: Wed, 14 Jun 2023 15:19:11 +0200 Subject: [PATCH] Revert "use floor in cm_to_px instead of round" This reverts commit 7e65d918b25575060ca50009d261d1e76dca6cae. --- webdriver/tests/support/fixtures_bidi.py | 5 ++--- webdriver/tests/support/image.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/webdriver/tests/support/fixtures_bidi.py b/webdriver/tests/support/fixtures_bidi.py index 3320f7d99a601e..860db936f93974 100644 --- a/webdriver/tests/support/fixtures_bidi.py +++ b/webdriver/tests/support/fixtures_bidi.py @@ -1,4 +1,3 @@ -from math import floor import base64 from tests.support.image import cm_to_px, png_dimensions, ImageDifference @@ -208,8 +207,8 @@ async def assert_pdf_dimensions(pdf, expected_dimensions): png = await render_pdf_to_png_bidi(pdf) width, height = png_dimensions(png) - assert floor(cm_to_px(expected_dimensions["height"])) == height - assert floor(cm_to_px(expected_dimensions["width"])) == width + assert (height - 1) <= cm_to_px(expected_dimensions["height"]) <= (height + 1) + assert (width - 1) <= cm_to_px(expected_dimensions["width"]) <= (width + 1) return assert_pdf_dimensions diff --git a/webdriver/tests/support/image.py b/webdriver/tests/support/image.py index 87a00bca5ec648..055ebe71fbc568 100644 --- a/webdriver/tests/support/image.py +++ b/webdriver/tests/support/image.py @@ -8,7 +8,7 @@ def cm_to_px(cm): - return cm * PPI / inch_in_cm + return round(cm * PPI / inch_in_cm) def px_to_cm(px):