test_ranking.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import unittest
  2. from wheel.pep425tags import get_supported
  3. from wheel.install import WheelFile
  4. WHEELPAT = "%(name)s-%(ver)s-%(pyver)s-%(abi)s-%(arch)s.whl"
  5. def make_wheel(name, ver, pyver, abi, arch):
  6. name = WHEELPAT % dict(name=name, ver=ver, pyver=pyver, abi=abi,
  7. arch=arch)
  8. return WheelFile(name)
  9. # This relies on the fact that generate_supported will always return the
  10. # exact pyver, abi, and architecture for its first (best) match.
  11. sup = get_supported()
  12. pyver, abi, arch = sup[0]
  13. genver = 'py' + pyver[2:]
  14. majver = genver[:3]
  15. COMBINATIONS = (
  16. ('bar', '0.9', 'py2.py3', 'none', 'any'),
  17. ('bar', '0.9', majver, 'none', 'any'),
  18. ('bar', '0.9', genver, 'none', 'any'),
  19. ('bar', '0.9', pyver, abi, arch),
  20. ('bar', '1.3.2', majver, 'none', 'any'),
  21. ('bar', '3.1', genver, 'none', 'any'),
  22. ('bar', '3.1', pyver, abi, arch),
  23. ('foo', '1.0', majver, 'none', 'any'),
  24. ('foo', '1.1', pyver, abi, arch),
  25. ('foo', '2.1', majver + '0', 'none', 'any'),
  26. # This will not be compatible for Python x.0. Beware when we hit Python
  27. # 4.0, and don't test with 3.0!!!
  28. ('foo', '2.1', majver + '1', 'none', 'any'),
  29. ('foo', '2.1', pyver , 'none', 'any'),
  30. ('foo', '2.1', pyver , abi, arch),
  31. )
  32. WHEELS = [ make_wheel(*args) for args in COMBINATIONS ]
  33. class TestRanking(unittest.TestCase):
  34. def test_comparison(self):
  35. for i in range(len(WHEELS)-1):
  36. for j in range(i):
  37. self.assertTrue(WHEELS[j]<WHEELS[i])