Skip to content

Commit 98d6c3b

Browse files
Restore pyroma test for iOS (#9116)
Co-authored-by: Andrew Murray <[email protected]>
1 parent 162836a commit 98d6c3b

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

Tests/test_image_access.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,4 +317,8 @@ def test_embeddable(self) -> None:
317317
assert process.returncode == 0
318318

319319
def teardown_method(self) -> None:
320-
os.remove("embed_pil.c")
320+
try:
321+
os.remove("embed_pil.c")
322+
except FileNotFoundError:
323+
# If the test was skipped or failed, the file won't exist
324+
pass

Tests/test_pyroma.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,38 @@
11
from __future__ import annotations
22

3+
from importlib.metadata import metadata
4+
35
import pytest
46

57
from PIL import __version__
68

79
pyroma = pytest.importorskip("pyroma", reason="Pyroma not installed")
810

911

12+
def map_metadata_keys(metadata):
13+
# Convert installed wheel metadata into canonical Core Metadata 2.4 format.
14+
# This was a utility method in pyroma 4.3.3; it was removed in 5.0.
15+
# This implementation is constructed from the relevant logic from
16+
# Pyroma 5.0's `build_metadata()` implementation. This has been submitted
17+
# upstream to Pyroma as https://github.com/regebro/pyroma/pull/116,
18+
# so it may be possible to simplify this test in future.
19+
data = {}
20+
for key in set(metadata.keys()):
21+
value = metadata.get_all(key)
22+
key = pyroma.projectdata.normalize(key)
23+
24+
if len(value) == 1:
25+
value = value[0]
26+
if value.strip() == "UNKNOWN":
27+
continue
28+
29+
data[key] = value
30+
return data
31+
32+
1033
def test_pyroma() -> None:
1134
# Arrange
12-
data = pyroma.projectdata.get_data(".")
35+
data = map_metadata_keys(metadata("Pillow"))
1336

1437
# Act
1538
rating = pyroma.ratings.rate(data)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ optional-dependencies.tests = [
6868
"markdown2",
6969
"olefile",
7070
"packaging",
71-
"pyroma",
71+
"pyroma>=5",
7272
"pytest",
7373
"pytest-cov",
7474
"pytest-timeout",

0 commit comments

Comments
 (0)