Files
cibuildwheel/unit_test/build_ids_test.py
T
Henry Schreiner b21d76ae03 docs: add missing cp314-pyodide_wasm32 to build-id table (#2947)
* docs: add missing cp314-pyodide_wasm32 to build-id table

The build-id table in docs/options.md is hand-maintained, so a new
identifier can be missed when build-platforms.toml changes. Add a unit
test that checks every identifier appears in the table to guard against
this.

Assisted-by: ClaudeCode:claude-opus-4.8

* test: skip docs table check when docs/options.md is absent

Assisted-by: ClaudeCode:claude-opus-4.8
2026-07-24 14:55:24 -04:00

61 lines
1.8 KiB
Python

import tomllib
from pathlib import Path
import pytest
from packaging.version import Version
from cibuildwheel.extra import Printable, dump_python_configurations
from cibuildwheel.util import resources
OPTIONS_MD = Path(__file__).parents[1] / "docs" / "options.md"
def test_compare_configs() -> None:
txt = resources.BUILD_PLATFORMS.read_text()
with resources.BUILD_PLATFORMS.open("rb") as f2:
dict_txt = tomllib.load(f2)
new_txt = dump_python_configurations(dict_txt)
print(new_txt)
assert new_txt == txt
@pytest.mark.skipif(not OPTIONS_MD.is_file(), reason="docs/options.md not present")
def test_all_identifiers_in_docs_table() -> None:
# The build-id table in docs/options.md is hand-maintained; this guards
# against forgetting an identifier when build-platforms.toml changes.
docs = OPTIONS_MD.read_text()
identifiers = [
config["identifier"]
for configs in resources.read_all_configs().values()
for config in configs
]
missing = [i for i in identifiers if i not in docs]
assert not missing, f"Missing from docs/options.md build-id table: {missing}"
def test_dump_with_Version() -> None:
# MyPy doesn't understand deeply nested dicts correctly
example: dict[str, dict[str, list[dict[str, Printable]]]] = {
"windows": {
"python_configurations": [
{"identifier": "cp27-win32", "version": Version("2.7.18"), "arch": "32"},
{"identifier": "cp27-win_amd64", "version": "2.7.18", "arch": "64"},
]
}
}
result = """\
[windows]
python_configurations = [
{ identifier = "cp27-win32", version = "2.7.18", arch = "32" },
{ identifier = "cp27-win_amd64", version = "2.7.18", arch = "64" },
]
"""
output = dump_python_configurations(example)
print(output)
assert output == result