|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from importlib.metadata import metadata |
| 3 | +import subprocess |
| 4 | +import sys |
4 | 5 |
|
5 | 6 | import pytest |
6 | 7 |
|
7 | | -from PIL import __version__ |
8 | | - |
9 | | -TYPE_CHECKING = False |
10 | | - |
11 | | -if TYPE_CHECKING: |
12 | | - from importlib.metadata import PackageMetadata |
13 | | - |
14 | | -pyroma = pytest.importorskip("pyroma", reason="Pyroma not installed") |
15 | | - |
16 | | - |
17 | | -def map_metadata_keys(md: PackageMetadata) -> dict[str, str | list[str] | None]: |
18 | | - # Convert installed wheel metadata into canonical Core Metadata 2.4 format. |
19 | | - # This was a utility method in pyroma 4.3.3; it was removed in 5.0. |
20 | | - # This implementation is constructed from the relevant logic from |
21 | | - # Pyroma 5.0's `build_metadata()` implementation. This has been submitted |
22 | | - # upstream to Pyroma as https://github.com/regebro/pyroma/pull/116, |
23 | | - # so it may be possible to simplify this test in future. |
24 | | - data = {} |
25 | | - for key in set(md): |
26 | | - value = md.get_all(key) |
27 | | - key = pyroma.projectdata.normalize(key) |
28 | | - |
29 | | - if value is not None and len(value) == 1: |
30 | | - first_value = value[0] |
31 | | - if first_value.strip() != "UNKNOWN": |
32 | | - data[key] = first_value |
33 | | - else: |
34 | | - data[key] = value |
35 | | - return data |
| 8 | +pytest.importorskip("pyroma", reason="Pyroma not installed") |
36 | 9 |
|
37 | 10 |
|
38 | 11 | def test_pyroma() -> None: |
39 | | - # Arrange |
40 | | - data = map_metadata_keys(metadata("Pillow")) |
41 | | - |
42 | | - # Act |
43 | | - rating = pyroma.ratings.rate(data) |
44 | | - |
45 | | - # Assert |
46 | | - if "rc" in __version__: |
47 | | - # Pyroma needs to chill about RC versions and not kill all our tests. |
48 | | - assert rating == ( |
49 | | - 9, |
50 | | - ["The package's version number does not comply with PEP-386."], |
51 | | - ) |
52 | | - |
53 | | - else: |
54 | | - # Should have a perfect score |
55 | | - assert rating == (10, []) |
| 12 | + assert b"Final rating: 10/10\n" in subprocess.check_output( |
| 13 | + [sys.executable, "-m", "pyroma", "."] |
| 14 | + ) |
0 commit comments