chore: drop toml, use tomli (#876)
This is required to get TOML 1.0 support, and lightens our dependencies a bit.
This commit is contained in:
@@ -1,28 +1,32 @@
|
||||
import toml
|
||||
from typing import Dict, List
|
||||
|
||||
import tomli
|
||||
from packaging.version import Version
|
||||
|
||||
from cibuildwheel.extra import InlineArrayDictEncoder # noqa: E402
|
||||
from cibuildwheel.extra import Printable, dump_python_configurations
|
||||
from cibuildwheel.util import resources_dir
|
||||
|
||||
|
||||
def test_compare_configs():
|
||||
with open(resources_dir / "build-platforms.toml") as f:
|
||||
txt = f.read()
|
||||
with open(resources_dir / "build-platforms.toml") as f1:
|
||||
txt = f1.read()
|
||||
|
||||
dict_txt = toml.loads(txt)
|
||||
with open(resources_dir / "build-platforms.toml", "rb") as f2:
|
||||
dict_txt = tomli.load(f2)
|
||||
|
||||
new_txt = toml.dumps(dict_txt, encoder=InlineArrayDictEncoder()) # type: ignore
|
||||
new_txt = dump_python_configurations(dict_txt)
|
||||
print(new_txt)
|
||||
|
||||
assert new_txt == txt
|
||||
|
||||
|
||||
def test_dump_with_Version():
|
||||
example = {
|
||||
# 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": Version("2.7.18"), "arch": "64"},
|
||||
{"identifier": "cp27-win_amd64", "version": "2.7.18", "arch": "64"},
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -35,6 +39,6 @@ python_configurations = [
|
||||
]
|
||||
"""
|
||||
|
||||
output = toml.dumps(example, encoder=InlineArrayDictEncoder()) # type: ignore
|
||||
output = dump_python_configurations(example)
|
||||
print(output)
|
||||
assert output == result
|
||||
|
||||
Reference in New Issue
Block a user