Files
cibuildwheel/unit_test/build_ids_test.py
T

43 lines
1.1 KiB
Python
Raw Normal View History

import tomllib
2021-01-31 17:14:15 -05:00
from packaging.version import Version
2021-01-09 15:40:40 -05:00
2021-10-15 11:30:16 -04:00
from cibuildwheel.extra import Printable, dump_python_configurations
2025-01-27 20:35:56 +01:00
from cibuildwheel.util import resources
2021-01-09 15:40:40 -05:00
2026-04-01 10:23:02 -04:00
def test_compare_configs() -> None:
2025-01-27 20:35:56 +01:00
txt = resources.BUILD_PLATFORMS.read_text()
2021-01-09 15:40:40 -05:00
2025-01-27 20:35:56 +01:00
with resources.BUILD_PLATFORMS.open("rb") as f2:
2022-04-15 21:00:57 -07:00
dict_txt = tomllib.load(f2)
2021-01-09 15:40:40 -05:00
2021-10-15 11:30:16 -04:00
new_txt = dump_python_configurations(dict_txt)
2021-01-09 15:40:40 -05:00
print(new_txt)
assert new_txt == txt
2026-04-01 10:23:02 -04:00
def test_dump_with_Version() -> None:
2021-10-15 11:30:16 -04:00
# 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"},
2021-10-15 11:30:16 -04:00
{"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" },
]
"""
2021-10-15 11:30:16 -04:00
output = dump_python_configurations(example)
print(output)
assert output == result