Do not log URL of test images if there is no URL

This commit is contained in:
Andrew Murray 2024-01-20 21:04:57 +11:00
parent 9b6c1e3763
commit f7701e6596

View File

@ -91,12 +91,12 @@ def assert_image_equal(a: Image.Image, b: Image.Image, msg: str | None = None) -
assert a.mode == b.mode, msg or f"got mode {repr(a.mode)}, expected {repr(b.mode)}" assert a.mode == b.mode, msg or f"got mode {repr(a.mode)}, expected {repr(b.mode)}"
assert a.size == b.size, msg or f"got size {repr(a.size)}, expected {repr(b.size)}" assert a.size == b.size, msg or f"got size {repr(a.size)}, expected {repr(b.size)}"
if a.tobytes() != b.tobytes(): if a.tobytes() != b.tobytes():
if uploader: try:
try: url = upload(a, b)
url = upload(a, b) if url:
logger.error("URL for test images: %s", url) logger.error("URL for test images: %s", url)
except Exception: except Exception:
pass pass
pytest.fail(msg or "got different content") pytest.fail(msg or "got different content")
@ -130,12 +130,12 @@ def assert_image_similar(
+ f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}" + f" average pixel value difference {ave_diff:.4f} > epsilon {epsilon:.4f}"
) )
except Exception as e: except Exception as e:
if uploader: try:
try: url = upload(a, b)
url = upload(a, b) if url:
logger.exception("URL for test images: %s", url) logger.exception("URL for test images: %s", url)
except Exception: except Exception:
pass pass
raise e raise e