1
1
import sys
2
2
3
+ import pytest
4
+
3
5
from mock import patch
4
6
5
7
from pip ._internal import pep425tags
@@ -114,44 +116,58 @@ def test_manual_abi_dm_flags(self):
114
116
self .abi_tag_unicode ('dm' , {'Py_DEBUG' : True , 'WITH_PYMALLOC' : True })
115
117
116
118
117
- class TestManylinux1Tags (object ):
118
-
119
+ @pytest .mark .parametrize ('is_manylinux_compatible' , [
120
+ pep425tags .is_manylinux1_compatible ,
121
+ pep425tags .is_manylinux2010_compatible ,
122
+ ])
123
+ class TestManylinuxTags (object ):
124
+ """
125
+ Tests common to all manylinux tags (e.g. manylinux1, manylinux2010,
126
+ ...)
127
+ """
119
128
@patch ('pip._internal.pep425tags.get_platform' , lambda : 'linux_x86_64' )
120
129
@patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
121
130
lambda major , minor : True )
122
- def test_manylinux1_compatible_on_linux_x86_64 (self ):
131
+ def test_manylinux_compatible_on_linux_x86_64 (self ,
132
+ is_manylinux_compatible ):
123
133
"""
124
- Test that manylinux1 is enabled on linux_x86_64
134
+ Test that manylinuxes are enabled on linux_x86_64
125
135
"""
126
- assert pep425tags . is_manylinux1_compatible ()
136
+ assert is_manylinux_compatible ()
127
137
128
138
@patch ('pip._internal.pep425tags.get_platform' , lambda : 'linux_i686' )
129
139
@patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
130
140
lambda major , minor : True )
131
- def test_manylinux1_compatible_on_linux_i686 (self ):
141
+ def test_manylinux1_compatible_on_linux_i686 (self ,
142
+ is_manylinux_compatible ):
132
143
"""
133
144
Test that manylinux1 is enabled on linux_i686
134
145
"""
135
- assert pep425tags . is_manylinux1_compatible ()
146
+ assert is_manylinux_compatible ()
136
147
137
148
@patch ('pip._internal.pep425tags.get_platform' , lambda : 'linux_x86_64' )
138
149
@patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
139
150
lambda major , minor : False )
140
- def test_manylinux1_2 (self ):
151
+ def test_manylinux1_2 (self , is_manylinux_compatible ):
141
152
"""
142
153
Test that manylinux1 is disabled with incompatible glibc
143
154
"""
144
- assert not pep425tags . is_manylinux1_compatible ()
155
+ assert not is_manylinux_compatible ()
145
156
146
157
@patch ('pip._internal.pep425tags.get_platform' , lambda : 'arm6vl' )
147
158
@patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
148
159
lambda major , minor : True )
149
- def test_manylinux1_3 (self ):
160
+ def test_manylinux1_3 (self , is_manylinux_compatible ):
150
161
"""
151
162
Test that manylinux1 is disabled on arm6vl
152
163
"""
153
- assert not pep425tags . is_manylinux1_compatible ()
164
+ assert not is_manylinux_compatible ()
154
165
166
+
167
+ class TestManylinux1Tags (object ):
168
+
169
+ @patch ('pip._internal.pep425tags.is_manylinux2010_compatible' ,
170
+ lambda : False )
155
171
@patch ('pip._internal.pep425tags.get_platform' , lambda : 'linux_x86_64' )
156
172
@patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
157
173
lambda major , minor : True )
@@ -172,3 +188,50 @@ def test_manylinux1_tag_is_first(self):
172
188
assert arches == ['manylinux1_x86_64' , 'linux_x86_64' , 'any' ]
173
189
else :
174
190
assert arches == ['manylinux1_x86_64' , 'linux_x86_64' ]
191
+
192
+
193
+ class TestManylinux2010Tags (object ):
194
+
195
+ @patch ('pip._internal.pep425tags.get_platform' , lambda : 'linux_x86_64' )
196
+ @patch ('pip._internal.utils.glibc.have_compatible_glibc' ,
197
+ lambda major , minor : True )
198
+ @patch ('sys.platform' , 'linux2' )
199
+ def test_manylinux2010_tag_is_first (self ):
200
+ """
201
+ Test that the more specific tag manylinux2010 comes first.
202
+ """
203
+ groups = {}
204
+ for pyimpl , abi , arch in pep425tags .get_supported ():
205
+ groups .setdefault ((pyimpl , abi ), []).append (arch )
206
+
207
+ for arches in groups .values ():
208
+ if arches == ['any' ]:
209
+ continue
210
+ # Expect the most specific arch first:
211
+ if len (arches ) == 4 :
212
+ assert arches == ['manylinux2010_x86_64' ,
213
+ 'manylinux1_x86_64' ,
214
+ 'linux_x86_64' ,
215
+ 'any' ]
216
+ else :
217
+ assert arches == ['manylinux2010_x86_64' ,
218
+ 'manylinux1_x86_64' ,
219
+ 'linux_x86_64' ]
220
+
221
+ @pytest .mark .parametrize ("manylinux2010,manylinux1" , [
222
+ ("manylinux2010_x86_64" , "manylinux1_x86_64" ),
223
+ ("manylinux2010_i686" , "manylinux1_i686" ),
224
+ ])
225
+ def test_manylinux2010_implies_manylinux1 (self , manylinux2010 , manylinux1 ):
226
+ """
227
+ Specifying manylinux2010 implies manylinux1.
228
+ """
229
+ groups = {}
230
+ supported = pep425tags .get_supported (platform = manylinux2010 )
231
+ for pyimpl , abi , arch in supported :
232
+ groups .setdefault ((pyimpl , abi ), []).append (arch )
233
+
234
+ for arches in groups .values ():
235
+ if arches == ['any' ]:
236
+ continue
237
+ assert arches [:2 ] == [manylinux2010 , manylinux1 ]
0 commit comments