mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-13 16:54:45 +03:00
set verbosity to 0 before comparing image bytes
This commit is contained in:
parent
50f410c177
commit
56680b253c
|
@ -15,6 +15,9 @@ from packaging.version import parse as parse_version
|
||||||
|
|
||||||
from PIL import Image, ImageMath, features
|
from PIL import Image, ImageMath, features
|
||||||
|
|
||||||
|
# overridden in conftest.py
|
||||||
|
pytestconfig = {"option": {"verbose": 0}}
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -88,7 +91,10 @@ def assert_image_equal(a, b, msg=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)}"
|
||||||
|
|
||||||
|
original_verbosity = pytestconfig.option.verbose
|
||||||
try:
|
try:
|
||||||
|
# set pytest's verbosity to 0 so that it doesn't show the full bytes diff
|
||||||
|
pytestconfig.option.verbose = 0
|
||||||
assert a.tobytes() == b.tobytes(), msg or "got different content"
|
assert a.tobytes() == b.tobytes(), msg or "got different content"
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if HAS_UPLOADER:
|
if HAS_UPLOADER:
|
||||||
|
@ -99,6 +105,8 @@ def assert_image_equal(a, b, msg=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
pytestconfig.option.verbose = original_verbosity
|
||||||
|
|
||||||
|
|
||||||
def assert_image_equal_tofile(a, filename, msg=None, mode=None):
|
def assert_image_equal_tofile(a, filename, msg=None, mode=None):
|
||||||
|
|
11
conftest.py
11
conftest.py
|
@ -1 +1,12 @@
|
||||||
pytest_plugins = ["Tests.helper"]
|
pytest_plugins = ["Tests.helper"]
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
"""
|
||||||
|
Keep a reference to pytest's configuration in our helper class.
|
||||||
|
This function is called by pytest each time the configuration is updated.
|
||||||
|
https://docs.pytest.org/en/latest/reference/reference.html#pytest.hookspec.pytest_configure
|
||||||
|
"""
|
||||||
|
import Tests.helper
|
||||||
|
|
||||||
|
Tests.helper.pytestconfig = config
|
||||||
|
|
Loading…
Reference in New Issue
Block a user