________________ ERROR at setup of test_gif_animation[internal] ________________
tmp_path_factory = TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7fff7e87f220>, _basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0'))
gif_animation_img = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/gif_animation_img0/in.gif')
request = <SubRequest 'gif_animation_pdf' for <Function test_gif_animation[internal]>>
@pytest.fixture(scope="session", params=["internal", "pikepdf"])
def gif_animation_pdf(tmp_path_factory, gif_animation_img, request):
tmpdir = tmp_path_factory.mktemp("gif_animation_pdf")
out_pdf = tmpdir / "out.pdf"
subprocess.check_call(
[
img2pdfprog,
"--producer=",
"--nodate",
"--engine=" + request.param,
"--output=" + str(out_pdf),
str(gif_animation_img),
]
)
pdfinfo = subprocess.check_output(["pdfinfo", str(out_pdf)])
assert re.search(
"^Pages: +2$", pdfinfo.decode("utf8"), re.MULTILINE
), identify.decode("utf8")
subprocess.check_call(["pdfseparate", str(out_pdf), str(tmpdir / "page-%d.pdf")])
for page in [1, 2]:
gif_animation_pdf_nr = tmpdir / ("page-%d.pdf" % page)
with pikepdf.open(gif_animation_pdf_nr) as p:
assert (
p.pages[0].Contents.read_bytes()
== b"q\n45.0000 0 0 45.0000 0.0000 0.0000 cm\n/Im0 Do\nQ"
)
assert p.pages[0].Resources.XObject.Im0.BitsPerComponent == 8
> assert p.pages[0].Resources.XObject.Im0.ColorSpace[0] == "/Indexed"
E TypeError: object is not an array
src/img2pdf_test.py:4696: TypeError
And:
y = pikepdf.open(out)
pydictx = rec(x.Root)
pydicty = rec(y.Root)
if f.endswith(os.path.sep + "animation.gif"):
# starting with PIL 8.2.0 the palette is half the size when encoding
# our test GIF image as PNG
#
# to still compare successfully, we truncate the expected palette
import PIL
if PIL.__version__ >= "8.2.0":
assert len(pydictx["/Pages"]["/Kids"]) == 2
for p in pydictx["/Pages"]["/Kids"]:
> assert p["/Resources"]["/XObject"]["/Im0"]["/ColorSpace"][2] == 127
E AssertionError: assert 'e' == 127
E +'e'
E -127
src/img2pdf_test.py:6724: AssertionError
Note that the number of failures is doubled due to test case parametrization.
So Fedora rebuilt its packages for the upcoming Fedora release and now 4 img2pdf test cases fail. Likely due to updated dependencies:
https://kojipkgs.fedoraproject.org//work/tasks/8785/81598785/build.log
```
________________ ERROR at setup of test_gif_animation[internal] ________________
tmp_path_factory = TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7fff7e87f220>, _basetemp=PosixPath('/tmp/pytest-of-mockbuild/pytest-0'))
gif_animation_img = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/gif_animation_img0/in.gif')
request = <SubRequest 'gif_animation_pdf' for <Function test_gif_animation[internal]>>
@pytest.fixture(scope="session", params=["internal", "pikepdf"])
def gif_animation_pdf(tmp_path_factory, gif_animation_img, request):
tmpdir = tmp_path_factory.mktemp("gif_animation_pdf")
out_pdf = tmpdir / "out.pdf"
subprocess.check_call(
[
img2pdfprog,
"--producer=",
"--nodate",
"--engine=" + request.param,
"--output=" + str(out_pdf),
str(gif_animation_img),
]
)
pdfinfo = subprocess.check_output(["pdfinfo", str(out_pdf)])
assert re.search(
"^Pages: +2$", pdfinfo.decode("utf8"), re.MULTILINE
), identify.decode("utf8")
subprocess.check_call(["pdfseparate", str(out_pdf), str(tmpdir / "page-%d.pdf")])
for page in [1, 2]:
gif_animation_pdf_nr = tmpdir / ("page-%d.pdf" % page)
with pikepdf.open(gif_animation_pdf_nr) as p:
assert (
p.pages[0].Contents.read_bytes()
== b"q\n45.0000 0 0 45.0000 0.0000 0.0000 cm\n/Im0 Do\nQ"
)
assert p.pages[0].Resources.XObject.Im0.BitsPerComponent == 8
> assert p.pages[0].Resources.XObject.Im0.ColorSpace[0] == "/Indexed"
E TypeError: object is not an array
src/img2pdf_test.py:4696: TypeError
```
And:
```
y = pikepdf.open(out)
pydictx = rec(x.Root)
pydicty = rec(y.Root)
if f.endswith(os.path.sep + "animation.gif"):
# starting with PIL 8.2.0 the palette is half the size when encoding
# our test GIF image as PNG
#
# to still compare successfully, we truncate the expected palette
import PIL
if PIL.__version__ >= "8.2.0":
assert len(pydictx["/Pages"]["/Kids"]) == 2
for p in pydictx["/Pages"]["/Kids"]:
> assert p["/Resources"]["/XObject"]["/Im0"]["/ColorSpace"][2] == 127
E AssertionError: assert 'e' == 127
E +'e'
E -127
src/img2pdf_test.py:6724: AssertionError
```
Note that the number of failures is doubled due to test case parametrization.
Yes, these failures are due to the Pillow 9.0.0 release which now treats GIF images differently.
I'm trying to fix this here: https://github.com/python-pillow/Pillow/pull/5974
josch
changed title from Tests fail on Fedora 36 to Help needed: GIF tests fail with Pillow 9.0.03 years ago
I think I do need help with https://github.com/python-pillow/Pillow/pull/5974 so if somebody has some time, then it would be appreciated if somebody could look into my attempts at letting Pillow emit palette images again instead of RGB iff the palette doesn't change between frames.
To indicate that I would appreciate help on this I changed the issue title accordingly.
@gms in Debian I just disabled the tests that fail with Pillow 9.0.0 for now:
https://salsa.debian.org/debian/img2pdf/-/blob/master/debian/patches/pillow9
Maybe you want to do the same in Fedora for now.
I think I do need help with https://github.com/python-pillow/Pillow/pull/5974 so if somebody has some time, then it would be appreciated if somebody could look into my attempts at letting Pillow emit palette images again instead of RGB iff the palette doesn't change between frames.
To indicate that I would appreciate help on this I changed the issue title accordingly.
I'm sorry that I can't help with the Pillow pull-request, because my knowledge is limited in that area.
Ok, I've disabled those tests like this:
```
PYTHONPATH=src %{__python3} -m pytest src/img2pdf_test.py -v -k 'not animation'
```
I'm sorry that I can't help with the Pillow pull-request, because my knowledge is limited in that area.
So Fedora rebuilt its packages for the upcoming Fedora release and now 4 img2pdf test cases fail. Likely due to updated dependencies:
https://kojipkgs.fedoraproject.org//work/tasks/8785/81598785/build.log
And:
Note that the number of failures is doubled due to test case parametrization.
Yes, these failures are due to the Pillow 9.0.0 release which now treats GIF images differently.
I'm trying to fix this here: https://github.com/python-pillow/Pillow/pull/5974
Tests fail on Fedora 36to Help needed: GIF tests fail with Pillow 9.0.0 3 years ago@gms in Debian I just disabled the tests that fail with Pillow 9.0.0 for now:
https://salsa.debian.org/debian/img2pdf/-/blob/master/debian/patches/pillow9
Maybe you want to do the same in Fedora for now.
I think I do need help with https://github.com/python-pillow/Pillow/pull/5974 so if somebody has some time, then it would be appreciated if somebody could look into my attempts at letting Pillow emit palette images again instead of RGB iff the palette doesn't change between frames.
To indicate that I would appreciate help on this I changed the issue title accordingly.
Ok, I've disabled those tests like this:
I'm sorry that I can't help with the Pillow pull-request, because my knowledge is limited in that area.