1
0

test_bdist.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # -*- coding: utf-8 -*-
  2. '''
  3. tests.integration.setup.test_bdist
  4. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. '''
  6. # Import python libs
  7. from __future__ import absolute_import, print_function, unicode_literals
  8. import os
  9. import re
  10. # Import Salt Testing libs
  11. from tests.support.runtests import RUNTIME_VARS
  12. from tests.support.unit import skipIf
  13. from tests.support.helpers import skip_if_not_root, VirtualEnv
  14. from tests.support.case import ModuleCase
  15. # Import salt libs
  16. import salt.utils.path
  17. import salt.utils.platform
  18. from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
  19. @skip_if_not_root
  20. @skipIf(salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, 'virtualenv not installed')
  21. class BdistSetupTest(ModuleCase):
  22. '''
  23. Tests for building and installing bdist_wheel packages
  24. '''
  25. def test_wheel_build(self):
  26. '''
  27. test building a bdist_wheel package
  28. '''
  29. # Let's create the testing virtualenv
  30. with VirtualEnv() as venv:
  31. ret = self.run_function('cmd.run', ['{0} setup.py bdist_wheel --dist-dir={1}'.format(venv.venv_python, venv.venv_dir)], cwd=RUNTIME_VARS.CODE_DIR)
  32. for _file in os.listdir(venv.venv_dir):
  33. if _file.endswith('whl'):
  34. whl = os.path.join(venv.venv_dir, _file)
  35. break
  36. ret = self.run_function('pip.install', pkgs=whl, bin_env=venv.venv_dir)
  37. # Let's ensure the version is correct
  38. pip_ver = self.run_function('pip.list', bin_env=venv.venv_dir).get('salt')
  39. whl_ver = [x for x in whl.split('/')[-1:][0].split('-') if re.search(r'^\d.\d*', x)][0]
  40. assert pip_ver == whl_ver.replace('_', '-')