test_bdist.py 1.8 KB

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