test_install.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # Test wheel.
  2. # The file has the following contents:
  3. # hello.pyd
  4. # hello/hello.py
  5. # hello/__init__.py
  6. # test-1.0.data/data/hello.dat
  7. # test-1.0.data/headers/hello.dat
  8. # test-1.0.data/scripts/hello.sh
  9. # test-1.0.dist-info/WHEEL
  10. # test-1.0.dist-info/METADATA
  11. # test-1.0.dist-info/RECORD
  12. # The root is PLATLIB
  13. # So, some in PLATLIB, and one in each of DATA, HEADERS and SCRIPTS.
  14. import wheel.tool
  15. import wheel.pep425tags
  16. from wheel.install import WheelFile
  17. from tempfile import mkdtemp
  18. import shutil
  19. import os
  20. THISDIR = os.path.dirname(__file__)
  21. TESTWHEEL = os.path.join(THISDIR, 'test-1.0-py2.py3-none-win32.whl')
  22. def check(*path):
  23. return os.path.exists(os.path.join(*path))
  24. def test_install():
  25. tempdir = mkdtemp()
  26. def get_supported():
  27. return list(wheel.pep425tags.get_supported()) + [('py3', 'none', 'win32')]
  28. whl = WheelFile(TESTWHEEL, context=get_supported)
  29. assert whl.supports_current_python(get_supported)
  30. try:
  31. locs = {}
  32. for key in ('purelib', 'platlib', 'scripts', 'headers', 'data'):
  33. locs[key] = os.path.join(tempdir, key)
  34. os.mkdir(locs[key])
  35. whl.install(overrides=locs)
  36. assert len(os.listdir(locs['purelib'])) == 0
  37. assert check(locs['platlib'], 'hello.pyd')
  38. assert check(locs['platlib'], 'hello', 'hello.py')
  39. assert check(locs['platlib'], 'hello', '__init__.py')
  40. assert check(locs['data'], 'hello.dat')
  41. assert check(locs['headers'], 'hello.dat')
  42. assert check(locs['scripts'], 'hello.sh')
  43. assert check(locs['platlib'], 'test-1.0.dist-info', 'RECORD')
  44. finally:
  45. shutil.rmtree(tempdir)
  46. def test_install_tool():
  47. """Slightly improve coverage of wheel.install"""
  48. wheel.tool.install([TESTWHEEL], force=True, dry_run=True)