test_png_gray1 test cases started to fail on Fedora 38 #161

Closed
opened 2023-04-06 21:48:43 +00:00 by gms · 1 comment

On current Fedora 38, the test_png_gray1 test cases fail like this:

src/img2pdf_test.py::test_png_gray1[internal] ERROR                      [  7%]
src/img2pdf_test.py::test_png_gray1[pikepdf] ERROR                       [  7%]
[..]
        assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
>       assert identify[0]["image"].get("type") == "Bilevel", str(identify)
E       AssertionError: [{'version': '1.0', 'image': {'name': '/tmp/pytest-of-mockbuild/pytest-0/gray1_png0/gray1.png', 'baseName': 'gray1.png', 'permissions': 644, 'format': 'PNG', 'formatDescription': 'Portable Network Graphics', 'mimeType': 'image/png', 'class': 'PseudoClass', 'geometry': {'width': 60, 'height': 60, 'x': 0, 'y': 0}, 'units': 'Undefined', 'type': 'Grayscale', 'endianness': 'Undefined', 'colorspace': 'Gray', 'depth': 1, 'baseDepth': 1, 'channelDepth': {'gray': 1}, 'pixels': 3600, 'channelStatistics': {'gray': {'min': 0, 'max': 1, 'mean': 0.436111, 'median': 0, 'standardDeviation': 0.49597, 'kurtosis': -1.9342, 'skewness': 0.25756, 'entropy': 0.98819}}, 'colormapEntries': 2, 'colormap': ['#000000FF', '#FFFFFFFF'], 'renderingIntent': 'Undefined', 'gamma': 0.454545, 'matteColor': '#BDBDBDBDBDBD', 'backgroundColor': '#FFFFFFFFFFFF', 'borderColor': '#DFDFDFDFDFDF', 'transparentColor': '#000000000000', 'interlace': 'None', 'intensity': 'Undefined', 'compose': 'Over', 'pageGeometry': {'width': 60, 'height': 60, 'x': 0, 'y': 0}, 'dispose': 'Undefined', 'iterations': 0, 'compression': 'Zip', 'orientation': 'Undefined', 'properties': {'png:IHDR.bit-depth-orig': '1', 'png:IHDR.bit_depth': '1', 'png:IHDR.color-type-orig': '0', 'png:IHDR.color_type': '0 (Grayscale)', 'png:IHDR.interlace_method': '0 (Not interlaced)', 'png:IHDR.width,height': '60, 60', 'signature': '7cb2a4f4df5f29f3dcd3713b56f19caeb1074bdfee5baa5bfc3579735e655f66'}, 'tainted': False, 'filesize': '608B', 'numberPixels': '3600', 'pixelsPerSecond': '5.95654MB', 'userTime': '0.000u', 'elapsedTime': '0:01.000', 'version': 'ImageMagick 7.1.0-62 Q16-HDRI x86_64 20885 https://imagemagick.org'}}]
E       assert 'Grayscale' == 'Bilevel'
E         - Bilevel
E         + Grayscale
src/img2pdf_test.py:1584: AssertionError

Full log file: https://kojipkgs.fedoraproject.org/work/tasks/703/99130703/build.log

So it looks like an updated dependency such as newer ImageMagick version caused this.

To be honest, I'm not really sure what is more correct: to name the type of a gray colorspace image as 'Bilevel' or 'Grayscale' ...

On current Fedora 38, the test_png_gray1 test cases fail like this: ``` src/img2pdf_test.py::test_png_gray1[internal] ERROR [ 7%] src/img2pdf_test.py::test_png_gray1[pikepdf] ERROR [ 7%] [..] assert identify[0]["image"].get("colorspace") == "Gray", str(identify) > assert identify[0]["image"].get("type") == "Bilevel", str(identify) E AssertionError: [{'version': '1.0', 'image': {'name': '/tmp/pytest-of-mockbuild/pytest-0/gray1_png0/gray1.png', 'baseName': 'gray1.png', 'permissions': 644, 'format': 'PNG', 'formatDescription': 'Portable Network Graphics', 'mimeType': 'image/png', 'class': 'PseudoClass', 'geometry': {'width': 60, 'height': 60, 'x': 0, 'y': 0}, 'units': 'Undefined', 'type': 'Grayscale', 'endianness': 'Undefined', 'colorspace': 'Gray', 'depth': 1, 'baseDepth': 1, 'channelDepth': {'gray': 1}, 'pixels': 3600, 'channelStatistics': {'gray': {'min': 0, 'max': 1, 'mean': 0.436111, 'median': 0, 'standardDeviation': 0.49597, 'kurtosis': -1.9342, 'skewness': 0.25756, 'entropy': 0.98819}}, 'colormapEntries': 2, 'colormap': ['#000000FF', '#FFFFFFFF'], 'renderingIntent': 'Undefined', 'gamma': 0.454545, 'matteColor': '#BDBDBDBDBDBD', 'backgroundColor': '#FFFFFFFFFFFF', 'borderColor': '#DFDFDFDFDFDF', 'transparentColor': '#000000000000', 'interlace': 'None', 'intensity': 'Undefined', 'compose': 'Over', 'pageGeometry': {'width': 60, 'height': 60, 'x': 0, 'y': 0}, 'dispose': 'Undefined', 'iterations': 0, 'compression': 'Zip', 'orientation': 'Undefined', 'properties': {'png:IHDR.bit-depth-orig': '1', 'png:IHDR.bit_depth': '1', 'png:IHDR.color-type-orig': '0', 'png:IHDR.color_type': '0 (Grayscale)', 'png:IHDR.interlace_method': '0 (Not interlaced)', 'png:IHDR.width,height': '60, 60', 'signature': '7cb2a4f4df5f29f3dcd3713b56f19caeb1074bdfee5baa5bfc3579735e655f66'}, 'tainted': False, 'filesize': '608B', 'numberPixels': '3600', 'pixelsPerSecond': '5.95654MB', 'userTime': '0.000u', 'elapsedTime': '0:01.000', 'version': 'ImageMagick 7.1.0-62 Q16-HDRI x86_64 20885 https://imagemagick.org'}}] E assert 'Grayscale' == 'Bilevel' E - Bilevel E + Grayscale src/img2pdf_test.py:1584: AssertionError ``` Full log file: https://kojipkgs.fedoraproject.org/work/tasks/703/99130703/build.log So it looks like an updated dependency such as newer ImageMagick version caused this. To be honest, I'm not really sure what is more correct: to name the type of a gray colorspace image as 'Bilevel' or 'Grayscale' ...
gms changed title from test_png_gray1 test cases started to fail on Fedora Rawhide to test_png_gray1 test cases started to fail on Fedora 38 2023-04-06 21:52:56 +00:00
Owner

I think the test can just accept both values because the line below checks:

assert identify[0]["image"].get("depth") == 1

So even if we call this a Grayscale image, it will still be a 2-color Grayscale which is what we want to assure here.

Can you confirm that this patch fixes the issue:

diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py
index f89fa74..342a120 100755
--- a/src/img2pdf_test.py
+++ b/src/img2pdf_test.py
@@ -1628,7 +1628,7 @@ def png_gray1_img(tmp_path_factory, tmp_gray1_png):
         "y": 0,
     }, str(identify)
     assert identify[0]["image"].get("colorspace") == "Gray", str(identify)
-    assert identify[0]["image"].get("type") == "Bilevel", str(identify)
+    assert identify[0]["image"].get("type") in ["Bilevel", "Grayscale"], str(identify)
     assert identify[0]["image"].get("depth") == 1, str(identify)
     assert identify[0]["image"].get("pageGeometry") == {
         "width": 60,
I think the test can just accept both values because the line below checks: assert identify[0]["image"].get("depth") == 1 So even if we call this a Grayscale image, it will still be a 2-color Grayscale which is what we want to assure here. Can you confirm that this patch fixes the issue: ```patch diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py index f89fa74..342a120 100755 --- a/src/img2pdf_test.py +++ b/src/img2pdf_test.py @@ -1628,7 +1628,7 @@ def png_gray1_img(tmp_path_factory, tmp_gray1_png): "y": 0, }, str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify) - assert identify[0]["image"].get("type") == "Bilevel", str(identify) + assert identify[0]["image"].get("type") in ["Bilevel", "Grayscale"], str(identify) assert identify[0]["image"].get("depth") == 1, str(identify) assert identify[0]["image"].get("pageGeometry") == { "width": 60, ```
josch closed this issue 2023-06-11 12:46:14 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: josch/img2pdf#161
No description provided.