|
5 | 5 | from mock import patch, Mock |
6 | 6 |
|
7 | 7 | from pip._vendor import pkg_resources |
8 | | -from pip import wheel |
| 8 | +from pip import pep425tags, wheel |
9 | 9 | from pip.exceptions import InvalidWheelFilename, UnsupportedWheel |
10 | 10 | from pip.util import unpack_file |
11 | 11 |
|
@@ -149,6 +149,90 @@ def test_not_supported_version(self): |
149 | 149 | w = wheel.Wheel('simple-0.1-py2-none-any.whl') |
150 | 150 | assert not w.supported(tags=[('py1', 'none', 'any')]) |
151 | 151 |
|
| 152 | + @patch('sys.platform', 'darwin') |
| 153 | + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') |
| 154 | + @patch('pip.pep425tags.get_platform', lambda: 'macosx_10_9_intel') |
| 155 | + def test_supported_osx_version(self): |
| 156 | + """ |
| 157 | + Wheels built for OS X 10.6 are supported on 10.9 |
| 158 | + """ |
| 159 | + tags = pep425tags.get_supported(['27'], False) |
| 160 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_6_intel.whl') |
| 161 | + assert w.supported(tags=tags) |
| 162 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl') |
| 163 | + assert w.supported(tags=tags) |
| 164 | + |
| 165 | + @patch('sys.platform', 'darwin') |
| 166 | + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') |
| 167 | + @patch('pip.pep425tags.get_platform', lambda: 'macosx_10_6_intel') |
| 168 | + def test_not_supported_osx_version(self): |
| 169 | + """ |
| 170 | + Wheels built for OS X 10.9 are not supported on 10.6 |
| 171 | + """ |
| 172 | + tags = pep425tags.get_supported(['27'], False) |
| 173 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl') |
| 174 | + assert not w.supported(tags=tags) |
| 175 | + |
| 176 | + @patch('sys.platform', 'darwin') |
| 177 | + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') |
| 178 | + def test_supported_multiarch_darwin(self): |
| 179 | + """ |
| 180 | + Multi-arch wheels (intel) are supported on components (i386, x86_64) |
| 181 | + """ |
| 182 | + with patch('pip.pep425tags.get_platform', |
| 183 | + lambda: 'macosx_10_5_universal'): |
| 184 | + universal = pep425tags.get_supported(['27'], False) |
| 185 | + with patch('pip.pep425tags.get_platform', |
| 186 | + lambda: 'macosx_10_5_intel'): |
| 187 | + intel = pep425tags.get_supported(['27'], False) |
| 188 | + with patch('pip.pep425tags.get_platform', |
| 189 | + lambda: 'macosx_10_5_x86_64'): |
| 190 | + x64 = pep425tags.get_supported(['27'], False) |
| 191 | + with patch('pip.pep425tags.get_platform', |
| 192 | + lambda: 'macosx_10_5_i386'): |
| 193 | + i386 = pep425tags.get_supported(['27'], False) |
| 194 | + with patch('pip.pep425tags.get_platform', |
| 195 | + lambda: 'macosx_10_5_ppc'): |
| 196 | + ppc = pep425tags.get_supported(['27'], False) |
| 197 | + with patch('pip.pep425tags.get_platform', |
| 198 | + lambda: 'macosx_10_5_ppc64'): |
| 199 | + ppc64 = pep425tags.get_supported(['27'], False) |
| 200 | + |
| 201 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_intel.whl') |
| 202 | + assert w.supported(tags=intel) |
| 203 | + assert w.supported(tags=x64) |
| 204 | + assert w.supported(tags=i386) |
| 205 | + assert not w.supported(tags=universal) |
| 206 | + assert not w.supported(tags=ppc) |
| 207 | + assert not w.supported(tags=ppc64) |
| 208 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_universal.whl') |
| 209 | + assert w.supported(tags=universal) |
| 210 | + assert w.supported(tags=intel) |
| 211 | + assert w.supported(tags=x64) |
| 212 | + assert w.supported(tags=i386) |
| 213 | + assert w.supported(tags=ppc) |
| 214 | + assert w.supported(tags=ppc64) |
| 215 | + |
| 216 | + @patch('sys.platform', 'darwin') |
| 217 | + @patch('pip.pep425tags.get_abbr_impl', lambda: 'cp') |
| 218 | + def test_not_supported_multiarch_darwin(self): |
| 219 | + """ |
| 220 | + Single-arch wheels (x86_64) are not supported on multi-arch (intel) |
| 221 | + """ |
| 222 | + with patch('pip.pep425tags.get_platform', |
| 223 | + lambda: 'macosx_10_5_universal'): |
| 224 | + universal = pep425tags.get_supported(['27'], False) |
| 225 | + with patch('pip.pep425tags.get_platform', |
| 226 | + lambda: 'macosx_10_5_intel'): |
| 227 | + intel = pep425tags.get_supported(['27'], False) |
| 228 | + |
| 229 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_i386.whl') |
| 230 | + assert not w.supported(tags=intel) |
| 231 | + assert not w.supported(tags=universal) |
| 232 | + w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_x86_64.whl') |
| 233 | + assert not w.supported(tags=intel) |
| 234 | + assert not w.supported(tags=universal) |
| 235 | + |
152 | 236 | def test_support_index_min(self): |
153 | 237 | """ |
154 | 238 | Test results from `support_index_min` |
|
0 commit comments