-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtest_build_wheels.py
112 lines (99 loc) · 9.61 KB
/
test_build_wheels.py
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
100
101
102
103
104
105
106
107
108
109
110
111
112
# ruff: noqa: E501
# line too long skip in ruff for whole file (formatting would be worst than long lines)
#
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
import unittest
from packaging.requirements import Requirement
from build_wheels import _change_specifier_logic
from build_wheels import yaml_to_requirement
class TestYAMLtoRequirement(unittest.TestCase):
def test_change_specifier_logic(self):
version_with_specifier = (('>0.9.0.2', '<0.9.0.2'),
('<0.9.0.2', '>0.9.0.2'),
('==0.9.0.2', '!=0.9.0.2'),
('>=0.9.0.2', '<=0.9.0.2'),
('<=0.9.0.2', '>=0.9.0.2'),
('!=0.9.0.2', '==0.9.0.2'),
('===0.9.0.2', '===0.9.0.2'),
)
for case in version_with_specifier:
self.assertEqual(f'{_change_specifier_logic(case[0])[0]}{_change_specifier_logic(case[0])[1]}', case[1])
def test_yaml_to_requirement(self):
test_requirements = {Requirement("platform;sys_platform == 'win32'"),
Requirement("platform;sys_platform == 'win32' or sys_platform == 'linux'"),
Requirement('version<42'),
Requirement('version<42,>50'),
Requirement("python;python_version > '3.10'"),
Requirement("python;python_version > '3.10' and python_version != '3.8'"),
Requirement("version-platform<=0.9.0.2;sys_platform == 'win32'"),
Requirement("version-platform<=0.9.0.2,>0.9.1;sys_platform == 'win32'"),
Requirement("version-platform<=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux'"),
Requirement("version-platform<=0.9.0.2,>0.9.1;sys_platform == 'win32' or sys_platform == 'linux'"),
Requirement("version-python<=0.9.0.2;python_version < '3.8'"),
Requirement("version-python<=0.9.0.2,>0.9.1;python_version < '3.8'"),
Requirement("version-python<=0.9.0.2;python_version < '3.8' and python_version > '3.11'"),
Requirement("version-python<=0.9.0.2,>0.9.1;python_version < '3.8' and python_version > '3.11'"),
Requirement("platform-python;sys_platform == 'win32' and python_version < '3.8'"),
Requirement("platform-python;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8'"),
Requirement("platform-python;sys_platform == 'win32' and python_version < '3.8' and python_version > '3.11'"),
Requirement("platform-python;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python<=0.9.0.2;sys_platform == 'win32' and python_version < '3.8'"),
Requirement("version-platform-python<=0.9.0.2,>0.9.1;sys_platform == 'win32' and python_version < '3.8'"),
Requirement("version-platform-python<=0.9.0.2,>0.9.1;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8'"),
Requirement("version-platform-python<=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8'"),
Requirement("version-platform-python<=0.9.0.2;sys_platform == 'win32' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python<=0.9.0.2,>0.9.1;sys_platform == 'win32' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python<=0.9.0.2,>0.9.1;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python<=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8' and python_version > '3.11'"),
}
self.assertEqual(yaml_to_requirement('test/test_list.yaml'), test_requirements)
def test_yaml_to_requirement_exclude(self):
test_requirements_exclude = {Requirement("platform;sys_platform != 'win32'"),
Requirement("platform;sys_platform != 'win32' or sys_platform != 'linux'"),
Requirement('version>42'),
Requirement('version>42,<50'),
Requirement("python;python_version < '3.10'"),
Requirement("python;python_version < '3.10' and python_version == '3.8'"),
Requirement("version-platform>=0.9.0.2;sys_platform == 'win32'"),
Requirement("version-platform;sys_platform != 'win32'"),
Requirement("version-platform>=0.9.0.2,<0.9.1;sys_platform == 'win32'"),
Requirement("version-platform;sys_platform != 'win32'"),
Requirement("version-platform>=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux'"),
Requirement("version-platform;sys_platform != 'win32' or sys_platform != 'linux'"),
Requirement("version-platform>=0.9.0.2,<0.9.1;sys_platform == 'win32' or sys_platform == 'linux'"),
Requirement("version-platform;sys_platform != 'win32' or sys_platform != 'linux'"),
Requirement("version-python>=0.9.0.2;python_version < '3.8'"),
Requirement("version-python;python_version > '3.8'"),
Requirement("version-python>=0.9.0.2,<0.9.1;python_version < '3.8'"),
Requirement("version-python;python_version > '3.8'"),
Requirement("version-python>=0.9.0.2;python_version < '3.8' and python_version > '3.11'"),
Requirement("version-python;python_version > '3.8' and python_version < '3.11'"),
Requirement("version-python>=0.9.0.2,<0.9.1;python_version < '3.8' and python_version > '3.11'"),
Requirement("version-python;python_version > '3.8' and python_version < '3.11'"),
Requirement("platform-python;sys_platform != 'win32' and python_version > '3.8'"),
Requirement("platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8'"),
Requirement("platform-python;sys_platform != 'win32' and python_version > '3.8' and python_version < '3.11'"),
Requirement("platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8' and python_version < '3.11'"),
Requirement("version-platform-python>=0.9.0.2;sys_platform == 'win32' and python_version < '3.8'"),
Requirement("version-platform-python;sys_platform != 'win32' and python_version > '3.8'"),
Requirement("version-platform-python>=0.9.0.2,<0.9.1;sys_platform == 'win32' and python_version < '3.8'"),
Requirement("version-platform-python;sys_platform != 'win32' and python_version > '3.8'"),
Requirement("version-platform-python>=0.9.0.2,<0.9.1;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8'"),
Requirement("version-platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8'"),
Requirement("version-platform-python>=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8'"),
Requirement("version-platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8'"),
Requirement("version-platform-python>=0.9.0.2;sys_platform == 'win32' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python;sys_platform != 'win32' and python_version > '3.8' and python_version < '3.11'"),
Requirement("version-platform-python>=0.9.0.2,<0.9.1;sys_platform == 'win32' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python;sys_platform != 'win32' and python_version > '3.8' and python_version < '3.11'"),
Requirement("version-platform-python>=0.9.0.2,<0.9.1;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8' and python_version < '3.11'"),
Requirement("version-platform-python>=0.9.0.2;sys_platform == 'win32' or sys_platform == 'linux' and python_version < '3.8' and python_version > '3.11'"),
Requirement("version-platform-python;sys_platform != 'win32' or sys_platform != 'linux' and python_version > '3.8' and python_version < '3.11'"),
}
self.assertEqual(yaml_to_requirement('test/test_list.yaml', exclude=True), test_requirements_exclude)
if __name__ == '__main__':
unittest.main()