|
7 | 7 | import tomllib
|
8 | 8 | from typing import TYPE_CHECKING
|
9 | 9 |
|
| 10 | +import pytest |
| 11 | + |
10 | 12 | from tests import PROJECT_ROOT
|
11 | 13 |
|
12 | 14 | if TYPE_CHECKING:
|
|
15 | 17 | MAKE = shutil.which("gmake") or shutil.which("make")
|
16 | 18 |
|
17 | 19 |
|
18 |
| -def test_image_pipfiles(subtests: pytest_subtests.plugin.SubTests): |
19 |
| - for file in PROJECT_ROOT.glob("**/Pipfile"): |
20 |
| - with subtests.test(msg="checking Pipfile", pipfile=file): |
21 |
| - print(file) |
| 20 | +def test_image_pyprojects(subtests: pytest_subtests.plugin.SubTests): |
| 21 | + for file in PROJECT_ROOT.glob("**/pyproject.toml"): |
| 22 | + logging.info(file) |
| 23 | + with subtests.test(msg="checking pyproject.toml", pipfile=file): |
22 | 24 | directory = file.parent # "ubi9-python-3.11"
|
23 |
| - _ubi, _lang, python = directory.name.split("-") |
| 25 | + try: |
| 26 | + _ubi, _lang, python = directory.name.split("-") |
| 27 | + except ValueError: |
| 28 | + pytest.skip(f"skipping {directory.name}/pyproject.toml as it is not an image directory") |
24 | 29 |
|
25 | 30 | with open(file, "rb") as fp:
|
26 |
| - pipfile = tomllib.load(fp) |
27 |
| - assert "requires" in pipfile, "Pipfile is missing a [[requires]] section" |
28 |
| - assert pipfile["requires"]["python_version"] == python, ( |
29 |
| - "Pipfile does not declare the expected Python version" |
| 31 | + pyproject = tomllib.load(fp) |
| 32 | + assert "project" in pyproject, "pyproject.toml is missing a [project] section" |
| 33 | + assert "requires-python" in pyproject["project"], ( |
| 34 | + "pyproject.toml is missing a [project.requires-python] section" |
| 35 | + ) |
| 36 | + assert pyproject["project"]["requires-python"] == f"=={python}.*", ( |
| 37 | + "pyproject.toml does not declare the expected Python version" |
30 | 38 | )
|
31 | 39 |
|
32 | 40 |
|
|
0 commit comments