1
0
Fork 0
forked from josch/img2pdf

src/img2pdf_test.py: make endianness dependant on sys.byteorder (closes: )

This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-06-11 14:45:09 +02:00
parent 64d27f4a8b
commit 33139612f8
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -24,6 +24,8 @@ import xml.etree.ElementTree as ET
img2pdfprog = os.getenv("img2pdfprog", default="src/img2pdf.py")
BYTEORDER = "LSB" if sys.byteorder == "little" else "MSB"
ICC_PROFILE = None
ICC_PROFILE_PATHS = (
# Debian
@ -2362,7 +2364,7 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2381,9 +2383,10 @@ def tiff_float_img(tmp_path_factory, tmp_normal_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2426,7 +2429,7 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2440,9 +2443,10 @@ def tiff_cmyk8_img(tmp_path_factory, tmp_normal_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "separated"
@ -2488,7 +2492,7 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2502,9 +2506,10 @@ def tiff_cmyk16_img(tmp_path_factory, tmp_normal_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "separated"
@ -2540,7 +2545,7 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2554,9 +2559,10 @@ def tiff_rgb8_img(tmp_path_factory, tmp_normal_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2599,7 +2605,7 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2613,9 +2619,10 @@ def tiff_rgb12_img(tmp_path_factory, tmp_normal16_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2658,7 +2665,7 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2672,9 +2679,10 @@ def tiff_rgb14_img(tmp_path_factory, tmp_normal16_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2717,7 +2725,7 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2731,9 +2739,10 @@ def tiff_rgb16_img(tmp_path_factory, tmp_normal16_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2777,7 +2786,7 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2791,9 +2800,10 @@ def tiff_rgba8_img(tmp_path_factory, tmp_alpha_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2837,7 +2847,7 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2851,9 +2861,10 @@ def tiff_rgba16_img(tmp_path_factory, tmp_alpha_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unassociated"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -2896,7 +2907,7 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2910,9 +2921,10 @@ def tiff_gray1_img(tmp_path_factory, tmp_gray1_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black"
@ -2956,7 +2968,7 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -2970,9 +2982,10 @@ def tiff_gray2_img(tmp_path_factory, tmp_gray2_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black"
@ -3016,7 +3029,7 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3030,9 +3043,10 @@ def tiff_gray4_img(tmp_path_factory, tmp_gray4_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black"
@ -3076,7 +3090,7 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3090,9 +3104,10 @@ def tiff_gray8_img(tmp_path_factory, tmp_gray8_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black"
@ -3136,7 +3151,7 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3150,9 +3165,10 @@ def tiff_gray16_img(tmp_path_factory, tmp_gray16_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric")
== "min-is-black"
@ -3198,7 +3214,7 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3212,9 +3228,10 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -3241,7 +3258,7 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3255,9 +3272,10 @@ def tiff_multipage_img(tmp_path_factory, tmp_normal_png, tmp_inverse_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "RGB"
), str(identify)
@ -3293,7 +3311,7 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3309,9 +3327,10 @@ def tiff_palette1_img(tmp_path_factory, tmp_palette1_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify)
@ -3346,7 +3365,7 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3362,9 +3381,10 @@ def tiff_palette2_img(tmp_path_factory, tmp_palette2_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify)
@ -3399,7 +3419,7 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3415,9 +3435,10 @@ def tiff_palette4_img(tmp_path_factory, tmp_palette4_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify)
@ -3452,7 +3473,7 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -3467,9 +3488,10 @@ def tiff_palette8_img(tmp_path_factory, tmp_palette8_png):
assert (
identify[0]["image"].get("properties", {}).get("tiff:alpha") == "unspecified"
), str(identify)
assert identify[0]["image"].get("properties", {}).get("tiff:endian") == "lsb", str(
identify
)
assert (
identify[0]["image"].get("properties", {}).get("tiff:endian")
== BYTEORDER.lower()
), str(identify)
assert (
identify[0]["image"].get("properties", {}).get("tiff:photometric") == "palette"
), str(identify)
@ -4023,7 +4045,7 @@ def miff_cmyk8_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -4074,7 +4096,7 @@ def miff_cmyk16_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB
@ -4116,7 +4138,7 @@ def miff_rgb8_img(tmp_path_factory, tmp_normal_png):
endian = "endianess" if identify[0].get("version", "0") < "1.0" else "endianness"
assert identify[0]["image"].get(endian) in [
"Undefined",
"LSB",
BYTEORDER,
], str(
identify
) # FIXME: should be LSB