From b8bfa982186b6d1c7515c1625bd0fac90536a4ed Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Wed, 7 Apr 2021 08:06:59 +0200 Subject: [PATCH] src/img2pdf_test.py: cater for endianess->endianness in 1.0 output format --- src/img2pdf_test.py | 81 ++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 27 deletions(-) diff --git a/src/img2pdf_test.py b/src/img2pdf_test.py index 4c99350..813c1d5 100755 --- a/src/img2pdf_test.py +++ b/src/img2pdf_test.py @@ -1005,7 +1005,8 @@ def jpg_img(tmp_path_factory, tmp_normal_png): assert "resolution" not in identify[0]["image"] assert identify[0]["image"].get("units") == "Undefined", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") == "Undefined", str(identify) + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) == "Undefined", str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("depth") == 8, str(identify) assert identify[0]["image"].get("pageGeometry") == { @@ -2361,7 +2362,8 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -2417,7 +2419,8 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -2477,7 +2480,8 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "CMYK", str(identify) assert identify[0]["image"].get("type") == "ColorSeparation", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 16, str(identify) @@ -2527,7 +2531,8 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -2578,7 +2583,8 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 12, str(identify) @@ -2629,7 +2635,8 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 14, str(identify) @@ -2680,7 +2687,8 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 16, str(identify) @@ -2731,7 +2739,8 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -2782,7 +2791,8 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColorAlpha", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 16, str(identify) @@ -2831,7 +2841,8 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 1, str(identify) @@ -2881,7 +2892,8 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 2, str(identify) @@ -2931,7 +2943,8 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 4, str(identify) @@ -2981,7 +2994,8 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3031,7 +3045,8 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "Gray", str(identify) assert identify[0]["image"].get("type") == "Grayscale", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 16, str(identify) @@ -3085,7 +3100,8 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3128,7 +3144,8 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "TrueColor", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3178,7 +3195,8 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3229,7 +3247,8 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3280,7 +3299,8 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3331,7 +3351,8 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png): }, str(identify) assert identify[0]["image"].get("colorspace") == "sRGB", str(identify) assert identify[0]["image"].get("type") == "Palette", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 8, str(identify) @@ -3395,7 +3416,8 @@ def tiff_ccitt_lsb_m2l_white_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 1, str(identify) @@ -3476,7 +3498,8 @@ def tiff_ccitt_msb_m2l_white_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in [ + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in [ "Undefined", "MSB", ] # FIXME: should be MSB @@ -3558,7 +3581,8 @@ def tiff_ccitt_msb_l2m_white_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in [ + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in [ "Undefined", "MSB", ] # FIXME: should be MSB @@ -3645,7 +3669,8 @@ def tiff_ccitt_lsb_m2l_black_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 1, str(identify) @@ -3735,7 +3760,8 @@ def tiff_ccitt_nometa1_img(tmp_path_factory, tmp_gray1_png): }, 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("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("depth") == 1, str(identify) @@ -3819,7 +3845,8 @@ def tiff_ccitt_nometa2_img(tmp_path_factory, tmp_gray1_png): }, str(identify) assert identify[0]["image"].get("units") == "PixelsPerInch", str(identify) assert identify[0]["image"].get("type") == "Bilevel", str(identify) - assert identify[0]["image"].get("endianess") in ["Undefined", "LSB",], str( + endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness" + assert identify[0]["image"].get(endian) in ["Undefined", "LSB",], str( identify ) # FIXME: should be LSB assert identify[0]["image"].get("colorspace") == "Gray", str(identify)