mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Use virtualenv 20.0.10 for macosx tests
This commit is contained in:
parent
19bb6aae0c
commit
fdeae1f0e1
5 changed files with 73 additions and 25 deletions
|
@ -25,7 +25,7 @@ rfc3987
|
|||
salttesting==2017.6.1
|
||||
strict_rfc3339
|
||||
supervisor==3.3.5; python_version < '3'
|
||||
virtualenv
|
||||
virtualenv==20.0.10
|
||||
watchdog
|
||||
yamlordereddictloader
|
||||
vcert~=0.7.0
|
||||
|
|
|
@ -43,6 +43,37 @@ def __virtual__():
|
|||
return __virtualname__
|
||||
|
||||
|
||||
def virtualenv_ver(venv_bin, user=None, **kwargs):
|
||||
'''
|
||||
return virtualenv version if exists
|
||||
'''
|
||||
# Virtualenv package
|
||||
try:
|
||||
import virtualenv
|
||||
version = getattr(virtualenv, '__version__', None)
|
||||
if not version:
|
||||
version = virtualenv.virtualenv_version
|
||||
virtualenv_version_info = tuple(
|
||||
[int(i) for i in version.split('rc')[0].split('.')]
|
||||
)
|
||||
except ImportError:
|
||||
# Unable to import?? Let's parse the version from the console
|
||||
version_cmd = [venv_bin, '--version']
|
||||
ret = __salt__['cmd.run_all'](
|
||||
version_cmd, runas=user, python_shell=False, **kwargs
|
||||
)
|
||||
if ret['retcode'] > 0 or not ret['stdout'].strip():
|
||||
raise CommandExecutionError(
|
||||
'Unable to get the virtualenv version output using \'{0}\'. '
|
||||
'Returned data: {1}'.format(version_cmd, ret)
|
||||
)
|
||||
virtualenv_version_info = tuple(
|
||||
[int(i) for i in
|
||||
ret['stdout'].strip().split('rc')[0].split('.')]
|
||||
)
|
||||
return virtualenv_version_info
|
||||
|
||||
|
||||
def create(path,
|
||||
venv_bin=None,
|
||||
system_site_packages=False,
|
||||
|
@ -164,29 +195,7 @@ def create(path,
|
|||
)
|
||||
# <---- Stop the user if pyvenv only options are used ----------------
|
||||
|
||||
# Virtualenv package
|
||||
try:
|
||||
import virtualenv
|
||||
version = getattr(virtualenv, '__version__',
|
||||
virtualenv.virtualenv_version)
|
||||
virtualenv_version_info = tuple(
|
||||
[int(i) for i in version.split('rc')[0].split('.')]
|
||||
)
|
||||
except ImportError:
|
||||
# Unable to import?? Let's parse the version from the console
|
||||
version_cmd = [venv_bin, '--version']
|
||||
ret = __salt__['cmd.run_all'](
|
||||
version_cmd, runas=user, python_shell=False, **kwargs
|
||||
)
|
||||
if ret['retcode'] > 0 or not ret['stdout'].strip():
|
||||
raise CommandExecutionError(
|
||||
'Unable to get the virtualenv version output using \'{0}\'. '
|
||||
'Returned data: {1}'.format(version_cmd, ret)
|
||||
)
|
||||
virtualenv_version_info = tuple(
|
||||
[int(i) for i in
|
||||
ret['stdout'].strip().split('rc')[0].split('.')]
|
||||
)
|
||||
virtualenv_version_info = virtualenv_ver(venv_bin, user=user, **kwargs)
|
||||
|
||||
if distribute:
|
||||
if virtualenv_version_info >= (1, 10):
|
||||
|
|
|
@ -405,8 +405,12 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
pprint.pformat(ret)
|
||||
)
|
||||
)
|
||||
import salt.modules.virtualenv_mod
|
||||
msg = 'New python executable'
|
||||
if salt.modules.virtualenv_mod.virtualenv_ver(venv_dir) >= (20, 0, 2):
|
||||
msg = 'created virtual environment'
|
||||
self.assertIn(
|
||||
'New python executable',
|
||||
msg,
|
||||
ret['stdout'],
|
||||
msg='Expected STDOUT did not match. Full return dictionary:\n{}'.format(
|
||||
pprint.pformat(ret)
|
||||
|
|
|
@ -350,3 +350,31 @@ class VirtualenvTestCase(TestCase, LoaderModuleMockMixin):
|
|||
runas=None,
|
||||
python_shell=False
|
||||
)
|
||||
|
||||
def test_virtualenv_ver(self):
|
||||
'''
|
||||
test virtualenv_ver when there is no ImportError
|
||||
'''
|
||||
ret = virtualenv_mod.virtualenv_ver(venv_bin='pyvenv')
|
||||
assert ret == (1, 9, 1)
|
||||
|
||||
def test_virtualenv_ver_importerror(self):
|
||||
'''
|
||||
test virtualenv_ver when there is an ImportError
|
||||
'''
|
||||
with ForceImportErrorOn('virtualenv'):
|
||||
mock_ver = MagicMock(return_value={'retcode': 0, 'stdout': '1.9.1'})
|
||||
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock_ver}):
|
||||
ret = virtualenv_mod.virtualenv_ver(venv_bin='pyenv')
|
||||
assert ret == (1, 9, 1)
|
||||
|
||||
def test_virtualenv_ver_importerror_cmd_error(self):
|
||||
'''
|
||||
test virtualenv_ver when there is an ImportError
|
||||
and virtualenv --version does not return anything
|
||||
'''
|
||||
with ForceImportErrorOn('virtualenv'):
|
||||
mock_ver = MagicMock(return_value={'retcode': 0, 'stdout': ''})
|
||||
with patch.dict(virtualenv_mod.__salt__, {'cmd.run_all': mock_ver}):
|
||||
with self.assertRaises(CommandExecutionError):
|
||||
virtualenv_mod.virtualenv_ver(venv_bin='pyenv')
|
||||
|
|
|
@ -27,6 +27,7 @@ import salt.utils.files
|
|||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.modules.zcbuildout as buildout
|
||||
import salt.modules.virtualenv_mod
|
||||
import salt.modules.cmdmod as cmd
|
||||
from salt.ext import six
|
||||
|
||||
|
@ -466,6 +467,9 @@ class BuildoutOnlineTestCase(Base):
|
|||
|
||||
@requires_network()
|
||||
def test_run_buildout(self):
|
||||
if salt.modules.virtualenv_mod.virtualenv_ver(self.ppy_st) >= (20, 0, 0):
|
||||
self.skipTest("Skiping until upstream resolved https://github.com/pypa/virtualenv/issues/1715")
|
||||
|
||||
b_dir = os.path.join(self.tdir, 'b')
|
||||
ret = buildout.bootstrap(b_dir, buildout_ver=2, python=self.py_st)
|
||||
self.assertTrue(ret['status'])
|
||||
|
@ -477,6 +481,9 @@ class BuildoutOnlineTestCase(Base):
|
|||
|
||||
@requires_network()
|
||||
def test_buildout(self):
|
||||
if salt.modules.virtualenv_mod.virtualenv_ver(self.ppy_st) >= (20, 0, 0):
|
||||
self.skipTest("Skiping until upstream resolved https://github.com/pypa/virtualenv/issues/1715")
|
||||
|
||||
b_dir = os.path.join(self.tdir, 'b')
|
||||
ret = buildout.buildout(b_dir, buildout_ver=2, python=self.py_st)
|
||||
self.assertTrue(ret['status'])
|
||||
|
|
Loading…
Add table
Reference in a new issue