-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathvalidate_test.py
More file actions
99 lines (75 loc) · 3.45 KB
/
validate_test.py
File metadata and controls
99 lines (75 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from __future__ import annotations
import zipfile
import pytest
from packaging.tags import parse_tag
import validate
def test_info_nothing_supplied():
info = validate.Info.from_dct({})
expected = validate.Info(
validate_extras=None,
validate_incorrect_missing_deps=(),
validate_skip_imports=(),
)
assert info == expected
def test_info_all_supplied():
info = validate.Info.from_dct(
{
"validate_extras": "d",
"validate_incorrect_missing_deps": "six",
"validate_skip_imports": "uwsgidecorators",
}
)
expected = validate.Info(
validate_extras="d",
validate_incorrect_missing_deps=("six",),
validate_skip_imports=("uwsgidecorators",),
)
assert info == expected
def test_pythons_to_check_no_pythons_raises_error():
with pytest.raises(AssertionError) as excinfo:
validate._pythons_to_check(frozenset())
(msg,) = excinfo.value.args
assert msg == "no interpreters found for frozenset()"
def test_pythons_to_check_py2_ignored():
ret = validate._pythons_to_check(parse_tag("py2.py3-none-any"))
assert ret == ("python3.11", "python3.12", "python3.13", "python3.14")
def test_pythons_to_check_py3_gives_all():
ret = validate._pythons_to_check(parse_tag("py3-none-any"))
assert ret == ("python3.11", "python3.12", "python3.13", "python3.14")
def test_pythons_to_check_abi3():
tag = "cp37-abi3-manylinux1_x86_64"
ret = validate._pythons_to_check(parse_tag(tag))
assert ret == ("python3.11", "python3.12", "python3.13", "python3.14")
def test_pythons_to_check_minimum_abi3():
tag = "cp312-abi3-manylinux1_x86_64"
ret = validate._pythons_to_check(parse_tag(tag))
assert ret == ("python3.12", "python3.13", "python3.14")
def test_pythons_to_check_specific_cpython_tag():
tag = "cp311-cp311-manylinux1_aarch64.whl"
ret = validate._pythons_to_check(parse_tag(tag))
assert ret == ("python3.11",)
def test_pythons_to_check_multi_platform_with_musllinux():
"""Test that wheels with both compatible and incompatible platform tags are accepted."""
# Simulates a wheel like: py3-none-any.musllinux_1_2_x86_64
# The py3-none-any tag is always compatible, while musllinux might not be on all systems
tags = parse_tag("py3-none-any") | parse_tag("py3-none-musllinux_1_2_x86_64")
ret = validate._pythons_to_check(tags)
# Should succeed because at least one tag (py3-none-any) is compatible
assert ret == ("python3.11", "python3.12", "python3.13", "python3.14")
def test_top_imports_record(tmp_path):
whl = tmp_path.joinpath("distlib.whl")
with zipfile.ZipFile(whl, "w") as zipf:
with zipf.open("distlib-0.3.4.dist-info/RECORD", "w") as f:
f.write(
# simplified from the actual contents
b"distlib-0.3.4.dist-info/RECORD,,\n"
b"distlib/__init__.py,sha256=y-rKDBB99QJ3N1PJGAXQo89ou615aAeBjV2brBxKgM8,581\n"
b"distlib/__pycache__/index.cpython-38.pyc,,\n"
b"distlib/compat.py,sha256=tfoMrj6tujk7G4UC2owL6ArgDuCKabgBxuJRGZSmpko,41259\n"
# not actually present but to demonstrate behaviour
b"distlib/subpkg/__init__.py,,\n"
b"_distlib_backend.cpython-38-x86_64-linux-gnu.so,,\n"
b"distlib_top.py,,\n"
)
expected = ["distlib", "_distlib_backend", "distlib_top"]
assert validate._top_imports(str(whl)) == expected