2012-09-18 00:53:05 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
'''
|
2018-05-28 21:13:12 +00:00
|
|
|
:codeauthor: Pedro Algarvio (pedro@algarvio.me)
|
2013-09-16 16:24:00 +00:00
|
|
|
|
|
|
|
|
2018-05-07 21:41:20 +00:00
|
|
|
tests.integration.states.pip_state
|
2013-09-16 16:24:00 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2012-09-18 00:53:05 +00:00
|
|
|
'''
|
|
|
|
|
2012-11-06 12:44:53 +00:00
|
|
|
# Import python libs
|
2018-01-19 05:49:04 +00:00
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2016-09-15 03:38:13 +00:00
|
|
|
import errno
|
2012-09-18 00:53:05 +00:00
|
|
|
import os
|
2013-08-27 13:54:00 +00:00
|
|
|
import glob
|
2012-09-18 00:53:05 +00:00
|
|
|
import shutil
|
2018-03-15 18:06:53 +00:00
|
|
|
import sys
|
2012-09-18 00:53:05 +00:00
|
|
|
|
2018-04-25 16:01:52 +00:00
|
|
|
try:
|
|
|
|
import pwd
|
|
|
|
HAS_PWD = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_PWD = False
|
|
|
|
|
2013-06-27 12:45:55 +00:00
|
|
|
# Import Salt Testing libs
|
2018-05-07 17:17:01 +00:00
|
|
|
from tests.support.case import ModuleCase
|
2017-02-27 13:58:07 +00:00
|
|
|
from tests.support.helpers import (
|
2013-08-27 13:54:00 +00:00
|
|
|
destructiveTest,
|
2015-01-09 17:52:55 +00:00
|
|
|
requires_system_grains,
|
2017-04-04 17:57:27 +00:00
|
|
|
with_system_user,
|
2018-05-02 18:17:36 +00:00
|
|
|
skip_if_not_root,
|
|
|
|
with_tempdir
|
2013-08-27 13:54:00 +00:00
|
|
|
)
|
2018-05-07 17:17:01 +00:00
|
|
|
from tests.support.mixins import SaltReturnAssertsMixin
|
|
|
|
from tests.support.runtests import RUNTIME_VARS
|
|
|
|
from tests.support.unit import skipIf
|
|
|
|
|
2012-09-18 00:53:05 +00:00
|
|
|
# Import salt libs
|
2017-07-18 16:31:01 +00:00
|
|
|
import salt.utils.files
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
import salt.utils.path
|
2018-05-07 17:36:47 +00:00
|
|
|
import salt.utils.platform
|
2017-08-09 21:30:39 +00:00
|
|
|
import salt.utils.versions
|
2018-05-01 21:33:29 +00:00
|
|
|
import salt.utils.win_dacl
|
2018-04-25 16:01:52 +00:00
|
|
|
import salt.utils.win_functions
|
2018-05-10 19:03:31 +00:00
|
|
|
import salt.utils.win_runas
|
2014-01-11 19:19:29 +00:00
|
|
|
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
|
2016-04-29 17:49:29 +00:00
|
|
|
from salt.exceptions import CommandExecutionError
|
2012-09-18 00:53:05 +00:00
|
|
|
|
2014-11-22 10:51:11 +00:00
|
|
|
# Import 3rd-party libs
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
from salt.ext import six
|
2014-11-22 10:51:11 +00:00
|
|
|
|
2012-09-18 00:53:05 +00:00
|
|
|
|
2018-05-10 19:03:31 +00:00
|
|
|
def can_runas():
|
|
|
|
'''
|
|
|
|
Detect if we are running in a limited shell (winrm) and are un-able to use
|
2018-05-10 19:11:45 +00:00
|
|
|
the runas utility method.
|
2018-05-10 19:03:31 +00:00
|
|
|
'''
|
2018-05-15 16:26:54 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-05-10 19:03:31 +00:00
|
|
|
try:
|
2018-05-14 17:30:04 +00:00
|
|
|
salt.utils.win_runas.runas(
|
2018-05-10 19:03:31 +00:00
|
|
|
'cmd.exe /c echo 1', 'noexistuser', 'n0existp4ss',
|
|
|
|
)
|
2018-05-14 15:26:01 +00:00
|
|
|
except WindowsError as exc: # pylint: disable=undefined-variable
|
2018-05-10 19:03:31 +00:00
|
|
|
if exc.winerror == 5:
|
|
|
|
# Access Denied
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
CAN_RUNAS = can_runas()
|
|
|
|
|
|
|
|
|
2017-05-22 16:47:54 +00:00
|
|
|
class VirtualEnv(object):
|
|
|
|
def __init__(self, test, venv_dir):
|
|
|
|
self.venv_dir = venv_dir
|
|
|
|
self.test = test
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
ret = self.test.run_function('virtualenv.create', [self.venv_dir])
|
|
|
|
self.test.assertEqual(ret['retcode'], 0)
|
|
|
|
|
|
|
|
def __exit__(self, exc_type, exc_value, traceback):
|
|
|
|
if os.path.isdir(self.venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(self.venv_dir, ignore_errors=True)
|
2017-05-22 16:47:54 +00:00
|
|
|
|
|
|
|
|
Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.
A summary of the changes in this PR is as follows:
* Moves the following functions from `salt.utils` to new locations
(including a deprecation warning if invoked from `salt.utils`):
`to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
`dequote`, `is_hex`, `is_bin_str`, `rand_string`,
`contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
`which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
`is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
`is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
`is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
`salt/utils/__init__.py` for better organization, so we can keep the
deprecated ones separate from the ones yet to be deprecated as we
continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
such that it returns a string matching the passed size. Previously
this function would get `size` bytes from `os.urandom()`,
base64-encode it, and return the result, which would in most cases not
be equal to the passed size.
2017-07-25 01:47:15 +00:00
|
|
|
@skipIf(salt.utils.path.which_bin(KNOWN_BINARY_NAMES) is None, 'virtualenv not installed')
|
2017-04-03 16:04:09 +00:00
|
|
|
class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
|
2012-09-18 00:53:05 +00:00
|
|
|
|
2017-05-22 16:47:54 +00:00
|
|
|
@skip_if_not_root
|
2016-05-12 20:54:47 +00:00
|
|
|
def test_pip_installed_removed(self):
|
|
|
|
'''
|
|
|
|
Tests installed and removed states
|
|
|
|
'''
|
2017-03-13 20:34:28 +00:00
|
|
|
name = 'pudb'
|
|
|
|
if name in self.run_function('pip.list'):
|
|
|
|
self.skipTest('{0} is already installed, uninstall to run this test'.format(name))
|
|
|
|
ret = self.run_state('pip.installed', name=name)
|
2016-05-12 20:54:47 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2017-03-13 20:34:28 +00:00
|
|
|
ret = self.run_state('pip.removed', name=name)
|
2016-05-12 20:54:47 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
2017-05-22 16:47:54 +00:00
|
|
|
def test_pip_installed_removed_venv(self):
|
|
|
|
venv_dir = os.path.join(
|
|
|
|
RUNTIME_VARS.TMP, 'pip_installed_removed'
|
|
|
|
)
|
|
|
|
with VirtualEnv(self, venv_dir):
|
|
|
|
name = 'pudb'
|
|
|
|
ret = self.run_state('pip.installed', name=name, bin_env=venv_dir)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
ret = self.run_state('pip.removed', name=name, bin_env=venv_dir)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
|
2012-09-23 17:16:11 +00:00
|
|
|
def test_pip_installed_errors(self):
|
2012-11-06 12:44:53 +00:00
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, 'pip-installed-errors'
|
2012-11-06 12:44:53 +00:00
|
|
|
)
|
2017-05-17 20:12:35 +00:00
|
|
|
orig_shell = os.environ.get('SHELL')
|
2012-09-23 17:16:11 +00:00
|
|
|
try:
|
|
|
|
# Since we don't have the virtualenv created, pip.installed will
|
2017-05-17 20:12:35 +00:00
|
|
|
# throw an error.
|
2013-08-14 11:29:34 +00:00
|
|
|
# Example error strings:
|
2017-03-06 17:12:14 +00:00
|
|
|
# * "Error installing 'pep8': /tmp/pip-installed-errors: not found"
|
|
|
|
# * "Error installing 'pep8': /bin/sh: 1: /tmp/pip-installed-errors: not found"
|
|
|
|
# * "Error installing 'pep8': /bin/bash: /tmp/pip-installed-errors: No such file or directory"
|
2013-08-14 11:29:34 +00:00
|
|
|
os.environ['SHELL'] = '/bin/sh'
|
2012-09-23 17:16:11 +00:00
|
|
|
ret = self.run_function('state.sls', mods='pip-installed-errors')
|
2012-12-07 16:59:24 +00:00
|
|
|
self.assertSaltFalseReturn(ret)
|
|
|
|
self.assertSaltCommentRegexpMatches(
|
|
|
|
ret,
|
2017-03-06 17:12:14 +00:00
|
|
|
'Error installing \'pep8\':'
|
2012-12-07 16:59:24 +00:00
|
|
|
)
|
2012-09-23 17:16:11 +00:00
|
|
|
|
|
|
|
# We now create the missing virtualenv
|
|
|
|
ret = self.run_function('virtualenv.create', [venv_dir])
|
2012-11-06 12:44:53 +00:00
|
|
|
self.assertEqual(ret['retcode'], 0)
|
2012-09-23 17:16:11 +00:00
|
|
|
|
|
|
|
# The state should not have any issues running now
|
|
|
|
ret = self.run_function('state.sls', mods='pip-installed-errors')
|
2012-12-07 16:59:24 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2012-09-23 17:16:11 +00:00
|
|
|
finally:
|
2017-05-17 20:12:35 +00:00
|
|
|
if orig_shell is None:
|
|
|
|
# Didn't exist before, don't leave it there. This should never
|
|
|
|
# happen, but if it does, we don't want this test to affect
|
|
|
|
# others elsewhere in the suite.
|
|
|
|
os.environ.pop('SHELL')
|
|
|
|
else:
|
|
|
|
os.environ['SHELL'] = orig_shell
|
2012-09-23 17:16:11 +00:00
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2012-09-23 17:16:11 +00:00
|
|
|
|
2017-05-25 14:37:35 +00:00
|
|
|
@skipIf(six.PY3, 'Issue is specific to carbon module, which is PY2-only')
|
2018-05-07 17:36:47 +00:00
|
|
|
@skipIf(salt.utils.platform.is_windows(), "Carbon does not install in Windows")
|
2015-01-09 17:52:55 +00:00
|
|
|
@requires_system_grains
|
|
|
|
def test_pip_installed_weird_install(self, grains=None):
|
2016-09-13 17:35:38 +00:00
|
|
|
# First, check to see if this is running on CentOS 5 or MacOS.
|
|
|
|
# If so, skip this test.
|
2015-01-09 17:52:55 +00:00
|
|
|
if grains['os'] in ('CentOS',) and grains['osrelease_info'][0] in (5,):
|
|
|
|
self.skipTest('This test does not run reliably on CentOS 5')
|
2016-09-13 17:35:38 +00:00
|
|
|
if grains['os'] in ('MacOS',):
|
|
|
|
self.skipTest('This test does not run reliably on MacOS')
|
2015-01-09 17:52:55 +00:00
|
|
|
|
2012-09-25 11:24:54 +00:00
|
|
|
ographite = '/opt/graphite'
|
|
|
|
if os.path.isdir(ographite):
|
|
|
|
self.skipTest(
|
|
|
|
'You already have \'{0}\'. This test would overwrite this '
|
|
|
|
'directory'.format(ographite)
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
os.makedirs(ographite)
|
2013-05-04 02:53:53 +00:00
|
|
|
except OSError as err:
|
2016-09-15 03:38:13 +00:00
|
|
|
if err.errno == errno.EACCES:
|
2012-09-25 11:24:54 +00:00
|
|
|
# Permission denied
|
|
|
|
self.skipTest(
|
|
|
|
'You don\'t have the required permissions to run this test'
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(ographite):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(ographite, ignore_errors=True)
|
2012-09-25 11:24:54 +00:00
|
|
|
|
2017-04-03 16:04:09 +00:00
|
|
|
venv_dir = os.path.join(RUNTIME_VARS.TMP, 'pip-installed-weird-install')
|
2012-09-25 11:24:54 +00:00
|
|
|
try:
|
2016-09-15 03:38:13 +00:00
|
|
|
# We may be able to remove this, I had to add it because the custom
|
|
|
|
# modules from the test suite weren't available in the jinja
|
|
|
|
# context when running the call to state.sls that comes after.
|
|
|
|
self.run_function('saltutil.sync_modules')
|
2012-09-25 11:24:54 +00:00
|
|
|
# Since we don't have the virtualenv created, pip.installed will
|
2018-04-25 16:01:52 +00:00
|
|
|
# throw an error.
|
2012-09-25 11:24:54 +00:00
|
|
|
ret = self.run_function(
|
|
|
|
'state.sls', mods='pip-installed-weird-install'
|
|
|
|
)
|
2012-12-07 16:59:24 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2012-09-25 11:24:54 +00:00
|
|
|
|
2012-12-07 16:59:24 +00:00
|
|
|
# We cannot use assertInSaltComment here because we need to skip
|
|
|
|
# some of the state return parts
|
2014-11-22 10:51:11 +00:00
|
|
|
for key in six.iterkeys(ret):
|
2012-09-25 11:24:54 +00:00
|
|
|
self.assertTrue(ret[key]['result'])
|
2017-12-20 00:37:59 +00:00
|
|
|
if ret[key]['name'] != 'carbon < 1.1':
|
2012-09-25 11:24:54 +00:00
|
|
|
continue
|
|
|
|
self.assertEqual(
|
|
|
|
ret[key]['comment'],
|
2017-12-20 00:37:59 +00:00
|
|
|
'There was no error installing package \'carbon < 1.1\' '
|
2012-09-25 11:24:54 +00:00
|
|
|
'although it does not show when calling \'pip.freeze\'.'
|
|
|
|
)
|
2016-09-15 03:38:13 +00:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception('Expected state did not run')
|
2012-09-25 11:24:54 +00:00
|
|
|
finally:
|
2017-12-20 00:37:59 +00:00
|
|
|
if os.path.isdir(ographite):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(ographite, ignore_errors=True)
|
2012-09-25 11:24:54 +00:00
|
|
|
|
2012-09-23 17:16:11 +00:00
|
|
|
def test_issue_2028_pip_installed_state(self):
|
|
|
|
ret = self.run_function('state.sls', mods='issue-2028-pip-installed')
|
|
|
|
|
2012-11-06 12:44:53 +00:00
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, 'issue-2028-pip-installed'
|
2012-11-06 12:44:53 +00:00
|
|
|
)
|
2012-09-23 17:16:11 +00:00
|
|
|
|
2018-04-25 16:01:52 +00:00
|
|
|
pep8_bin = os.path.join(venv_dir, 'bin', 'pep8')
|
2018-05-07 17:36:47 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-04-25 16:01:52 +00:00
|
|
|
pep8_bin = os.path.join(venv_dir, 'Scripts', 'pep8.exe')
|
|
|
|
|
2012-09-23 17:16:11 +00:00
|
|
|
try:
|
2012-12-07 16:59:24 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2012-09-23 17:16:11 +00:00
|
|
|
self.assertTrue(
|
2018-04-25 16:01:52 +00:00
|
|
|
os.path.isfile(pep8_bin)
|
2012-09-23 17:16:11 +00:00
|
|
|
)
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2012-09-27 11:06:09 +00:00
|
|
|
|
|
|
|
def test_issue_2087_missing_pip(self):
|
2012-11-06 12:44:53 +00:00
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, 'issue-2087-missing-pip'
|
2012-11-06 12:44:53 +00:00
|
|
|
)
|
|
|
|
|
2012-09-27 11:06:09 +00:00
|
|
|
try:
|
|
|
|
# Let's create the testing virtualenv
|
2012-12-07 16:59:24 +00:00
|
|
|
ret = self.run_function('virtualenv.create', [venv_dir])
|
|
|
|
self.assertEqual(ret['retcode'], 0)
|
2012-09-27 11:06:09 +00:00
|
|
|
|
|
|
|
# Let's remove the pip binary
|
|
|
|
pip_bin = os.path.join(venv_dir, 'bin', 'pip')
|
2018-05-14 19:45:37 +00:00
|
|
|
site_dir = self.run_function('virtualenv.get_distribution_path', [venv_dir, 'pip'])
|
2018-05-07 17:36:47 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-04-25 16:01:52 +00:00
|
|
|
pip_bin = os.path.join(venv_dir, 'Scripts', 'pip.exe')
|
|
|
|
site_dir = os.path.join(venv_dir, 'lib', 'site-packages')
|
2012-09-27 11:06:09 +00:00
|
|
|
if not os.path.isfile(pip_bin):
|
|
|
|
self.skipTest(
|
|
|
|
'Failed to find the pip binary to the test virtualenv'
|
|
|
|
)
|
|
|
|
os.remove(pip_bin)
|
|
|
|
|
2018-04-25 16:01:52 +00:00
|
|
|
# Also remove the pip dir from site-packages
|
|
|
|
# This is needed now that we're using python -m pip instead of the
|
|
|
|
# pip binary directly. python -m pip will still work even if the
|
|
|
|
# pip binary is missing
|
|
|
|
shutil.rmtree(os.path.join(site_dir, 'pip'))
|
|
|
|
|
2012-09-27 11:06:09 +00:00
|
|
|
# Let's run the state which should fail because pip is missing
|
|
|
|
ret = self.run_function('state.sls', mods='issue-2087-missing-pip')
|
2012-12-07 16:59:24 +00:00
|
|
|
self.assertSaltFalseReturn(ret)
|
|
|
|
self.assertInSaltComment(
|
2013-08-18 04:46:33 +00:00
|
|
|
'Error installing \'pep8\': Could not find a `pip` binary',
|
|
|
|
ret
|
2012-09-27 11:06:09 +00:00
|
|
|
)
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2013-06-25 07:57:26 +00:00
|
|
|
|
2013-07-05 22:00:14 +00:00
|
|
|
def test_issue_5940_multiple_pip_mirrors(self):
|
2016-04-29 17:49:29 +00:00
|
|
|
'''
|
|
|
|
Test multiple pip mirrors. This test only works with pip < 7.0.0
|
|
|
|
'''
|
2013-07-05 22:00:14 +00:00
|
|
|
ret = self.run_function(
|
|
|
|
'state.sls', mods='issue-5940-multiple-pip-mirrors'
|
|
|
|
)
|
|
|
|
|
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, '5940-multiple-pip-mirrors'
|
2013-07-05 22:00:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
try:
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertTrue(
|
|
|
|
os.path.isfile(os.path.join(venv_dir, 'bin', 'pep8'))
|
|
|
|
)
|
2016-04-29 17:49:29 +00:00
|
|
|
except (AssertionError, CommandExecutionError):
|
|
|
|
pip_version = self.run_function('pip.version', [venv_dir])
|
2017-08-09 21:30:39 +00:00
|
|
|
if salt.utils.versions.compare(ver1=pip_version, oper='>=', ver2='7.0.0'):
|
2016-04-29 17:49:29 +00:00
|
|
|
self.skipTest('the --mirrors arg has been deprecated and removed in pip==7.0.0')
|
2013-07-05 22:00:14 +00:00
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2013-07-05 22:00:14 +00:00
|
|
|
|
2013-08-27 13:54:00 +00:00
|
|
|
@destructiveTest
|
2017-04-04 17:57:27 +00:00
|
|
|
@skip_if_not_root
|
2018-05-10 19:03:31 +00:00
|
|
|
@skipIf(not CAN_RUNAS, 'Runas support required')
|
2018-05-01 21:33:29 +00:00
|
|
|
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
|
|
|
password='PassWord1!')
|
2018-05-02 18:17:36 +00:00
|
|
|
@with_tempdir()
|
|
|
|
def test_issue_6912_wrong_owner(self, temp_dir, username):
|
2018-05-01 21:33:29 +00:00
|
|
|
# Setup virtual environment directory to be used throughout the test
|
2018-05-02 18:17:36 +00:00
|
|
|
venv_dir = os.path.join(temp_dir, '6912-wrong-owner')
|
2018-04-25 16:01:52 +00:00
|
|
|
|
2018-05-01 21:33:29 +00:00
|
|
|
# The virtual environment needs to be in a location that is accessible
|
|
|
|
# by both the user running the test and the runas user
|
2018-05-07 17:36:47 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-05-02 18:17:36 +00:00
|
|
|
salt.utils.win_dacl.set_permissions(temp_dir, username, 'full_control')
|
|
|
|
else:
|
|
|
|
uid = self.run_function('file.user_to_uid', [username])
|
|
|
|
os.chown(temp_dir, uid, -1)
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-01 21:33:29 +00:00
|
|
|
# Create the virtual environment
|
2013-08-27 13:54:00 +00:00
|
|
|
venv_create = self.run_function(
|
2018-05-01 21:33:29 +00:00
|
|
|
'virtualenv.create', [venv_dir], user=username,
|
|
|
|
password='PassWord1!')
|
2013-08-27 13:54:00 +00:00
|
|
|
if venv_create['retcode'] > 0:
|
2018-05-01 21:33:29 +00:00
|
|
|
self.skipTest('Failed to create testcase virtual environment: {0}'
|
|
|
|
''.format(venv_create))
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-01 21:33:29 +00:00
|
|
|
# pip install passing the package name in `name`
|
2018-05-02 18:17:36 +00:00
|
|
|
ret = self.run_state(
|
|
|
|
'pip.installed', name='pep8', user=username, bin_env=venv_dir,
|
2018-05-08 13:22:04 +00:00
|
|
|
password='PassWord1!')
|
2018-05-02 18:17:36 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-02 18:17:36 +00:00
|
|
|
if HAS_PWD:
|
|
|
|
uid = pwd.getpwnam(username).pw_uid
|
|
|
|
for globmatch in (os.path.join(venv_dir, '**', 'pep8*'),
|
|
|
|
os.path.join(venv_dir, '*', '**', 'pep8*'),
|
|
|
|
os.path.join(venv_dir, '*', '*', '**', 'pep8*')):
|
|
|
|
for path in glob.glob(globmatch):
|
|
|
|
if HAS_PWD:
|
|
|
|
self.assertEqual(uid, os.stat(path).st_uid)
|
2018-05-07 17:36:47 +00:00
|
|
|
elif salt.utils.platform.is_windows():
|
2013-08-29 20:21:23 +00:00
|
|
|
self.assertEqual(
|
2018-05-02 18:17:36 +00:00
|
|
|
salt.utils.win_dacl.get_owner(path), username)
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-01 21:33:29 +00:00
|
|
|
@destructiveTest
|
|
|
|
@skip_if_not_root
|
2018-05-10 19:03:31 +00:00
|
|
|
@skipIf(not CAN_RUNAS, 'Runas support required')
|
2018-05-01 21:33:29 +00:00
|
|
|
@with_system_user('issue-6912', on_existing='delete', delete=True,
|
|
|
|
password='PassWord1!')
|
2018-05-02 18:17:36 +00:00
|
|
|
@with_tempdir()
|
|
|
|
def test_issue_6912_wrong_owner_requirements_file(self, temp_dir, username):
|
2018-05-01 21:33:29 +00:00
|
|
|
# Setup virtual environment directory to be used throughout the test
|
2018-05-02 18:17:36 +00:00
|
|
|
venv_dir = os.path.join(temp_dir, '6912-wrong-owner')
|
2018-05-01 21:33:29 +00:00
|
|
|
|
|
|
|
# The virtual environment needs to be in a location that is accessible
|
|
|
|
# by both the user running the test and the runas user
|
2018-05-07 17:36:47 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-05-02 18:17:36 +00:00
|
|
|
salt.utils.win_dacl.set_permissions(temp_dir, username, 'full_control')
|
|
|
|
else:
|
|
|
|
uid = self.run_function('file.user_to_uid', [username])
|
|
|
|
os.chown(temp_dir, uid, -1)
|
2018-05-01 21:33:29 +00:00
|
|
|
|
|
|
|
# Create the virtual environment again as it should have been removed
|
2013-08-27 13:56:37 +00:00
|
|
|
venv_create = self.run_function(
|
2018-05-01 21:33:29 +00:00
|
|
|
'virtualenv.create', [venv_dir], user=username,
|
|
|
|
password='PassWord1!')
|
2013-08-27 13:56:37 +00:00
|
|
|
if venv_create['retcode'] > 0:
|
2018-05-01 22:28:48 +00:00
|
|
|
self.skipTest('failed to create testcase virtual environment: {0}'
|
2018-05-01 21:33:29 +00:00
|
|
|
''.format(venv_create))
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-01 21:33:29 +00:00
|
|
|
# pip install using a requirements file
|
2013-08-29 20:21:23 +00:00
|
|
|
req_filename = os.path.join(
|
2018-05-10 15:16:02 +00:00
|
|
|
RUNTIME_VARS.TMP_STATE_TREE, 'issue-6912-requirements.txt'
|
2013-08-29 20:21:23 +00:00
|
|
|
)
|
2017-07-18 16:31:01 +00:00
|
|
|
with salt.utils.files.fopen(req_filename, 'wb') as reqf:
|
2018-01-22 16:56:19 +00:00
|
|
|
reqf.write(b'pep8\n')
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-02 18:17:36 +00:00
|
|
|
ret = self.run_state(
|
|
|
|
'pip.installed', name='', user=username, bin_env=venv_dir,
|
|
|
|
requirements='salt://issue-6912-requirements.txt',
|
2018-05-08 13:22:04 +00:00
|
|
|
password='PassWord1!')
|
2018-05-02 18:17:36 +00:00
|
|
|
self.assertSaltTrueReturn(ret)
|
2013-08-29 20:21:23 +00:00
|
|
|
|
2018-05-02 18:17:36 +00:00
|
|
|
if HAS_PWD:
|
|
|
|
uid = pwd.getpwnam(username).pw_uid
|
|
|
|
for globmatch in (os.path.join(venv_dir, '**', 'pep8*'),
|
|
|
|
os.path.join(venv_dir, '*', '**', 'pep8*'),
|
|
|
|
os.path.join(venv_dir, '*', '*', '**', 'pep8*')):
|
|
|
|
for path in glob.glob(globmatch):
|
|
|
|
if HAS_PWD:
|
|
|
|
self.assertEqual(uid, os.stat(path).st_uid)
|
2018-05-07 17:36:47 +00:00
|
|
|
elif salt.utils.platform.is_windows():
|
2018-05-02 18:17:36 +00:00
|
|
|
self.assertEqual(
|
|
|
|
salt.utils.win_dacl.get_owner(path), username)
|
2013-08-27 13:54:00 +00:00
|
|
|
|
2013-09-10 09:52:17 +00:00
|
|
|
def test_issue_6833_pip_upgrade_pip(self):
|
|
|
|
# Create the testing virtualenv
|
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, '6833-pip-upgrade-pip'
|
2013-09-10 09:52:17 +00:00
|
|
|
)
|
|
|
|
ret = self.run_function('virtualenv.create', [venv_dir])
|
2018-04-25 16:01:52 +00:00
|
|
|
|
2013-09-10 09:52:17 +00:00
|
|
|
try:
|
|
|
|
try:
|
|
|
|
self.assertEqual(ret['retcode'], 0)
|
|
|
|
self.assertIn(
|
|
|
|
'New python executable',
|
|
|
|
ret['stdout']
|
|
|
|
)
|
|
|
|
except AssertionError:
|
|
|
|
import pprint
|
|
|
|
pprint.pprint(ret)
|
|
|
|
raise
|
|
|
|
|
|
|
|
# Let's install a fixed version pip over whatever pip was
|
|
|
|
# previously installed
|
|
|
|
ret = self.run_function(
|
2017-05-22 16:52:32 +00:00
|
|
|
'pip.install', ['pip==8.0'], upgrade=True,
|
2013-09-10 09:52:17 +00:00
|
|
|
bin_env=venv_dir
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
self.assertEqual(ret['retcode'], 0)
|
|
|
|
self.assertIn(
|
|
|
|
'Successfully installed pip',
|
|
|
|
ret['stdout']
|
|
|
|
)
|
|
|
|
except AssertionError:
|
|
|
|
import pprint
|
|
|
|
pprint.pprint(ret)
|
|
|
|
raise
|
|
|
|
|
2017-05-22 16:52:32 +00:00
|
|
|
# Let's make sure we have pip 8.0 installed
|
2013-09-10 09:52:17 +00:00
|
|
|
self.assertEqual(
|
2013-09-11 09:54:43 +00:00
|
|
|
self.run_function('pip.list', ['pip'], bin_env=venv_dir),
|
2017-05-22 16:52:32 +00:00
|
|
|
{'pip': '8.0.0'}
|
2013-09-10 09:52:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Now the actual pip upgrade pip test
|
|
|
|
ret = self.run_state(
|
2017-05-22 16:52:32 +00:00
|
|
|
'pip.installed', name='pip==8.0.1', upgrade=True,
|
2013-09-10 09:52:17 +00:00
|
|
|
bin_env=venv_dir
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
self.assertSaltTrueReturn(ret)
|
2018-04-25 16:01:52 +00:00
|
|
|
self.assertSaltStateChangesEqual(
|
|
|
|
ret, {'pip==8.0.1': 'Installed'})
|
2013-09-10 09:52:17 +00:00
|
|
|
except AssertionError:
|
|
|
|
import pprint
|
|
|
|
pprint.pprint(ret)
|
|
|
|
raise
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2013-09-10 09:52:17 +00:00
|
|
|
|
2013-11-02 22:40:09 +00:00
|
|
|
def test_pip_installed_specific_env(self):
|
|
|
|
# Create the testing virtualenv
|
|
|
|
venv_dir = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP, 'pip-installed-specific-env'
|
2013-11-02 22:40:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Let's write a requirements file
|
|
|
|
requirements_file = os.path.join(
|
2017-04-03 16:04:09 +00:00
|
|
|
RUNTIME_VARS.TMP_PRODENV_STATE_TREE, 'prod-env-requirements.txt'
|
2013-11-02 22:40:09 +00:00
|
|
|
)
|
2017-07-18 16:31:01 +00:00
|
|
|
with salt.utils.files.fopen(requirements_file, 'wb') as reqf:
|
2018-01-22 16:56:19 +00:00
|
|
|
reqf.write(b'pep8\n')
|
2013-11-02 22:40:09 +00:00
|
|
|
|
|
|
|
try:
|
2015-01-05 22:20:18 +00:00
|
|
|
self.run_function('virtualenv.create', [venv_dir])
|
2013-11-02 22:40:09 +00:00
|
|
|
|
|
|
|
# The requirements file should not be found the base environment
|
|
|
|
ret = self.run_state(
|
|
|
|
'pip.installed', name='', bin_env=venv_dir,
|
|
|
|
requirements='salt://prod-env-requirements.txt'
|
|
|
|
)
|
|
|
|
self.assertSaltFalseReturn(ret)
|
|
|
|
self.assertInSaltComment(
|
|
|
|
"'salt://prod-env-requirements.txt' not found", ret
|
|
|
|
)
|
|
|
|
|
|
|
|
# The requirements file must be found in the prod environment
|
|
|
|
ret = self.run_state(
|
2013-11-06 23:36:40 +00:00
|
|
|
'pip.installed', name='', bin_env=venv_dir, saltenv='prod',
|
2013-11-02 22:40:09 +00:00
|
|
|
requirements='salt://prod-env-requirements.txt'
|
|
|
|
)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertInSaltComment(
|
2015-01-05 22:36:45 +00:00
|
|
|
'Successfully processed requirements file '
|
|
|
|
'salt://prod-env-requirements.txt', ret
|
2013-11-02 22:40:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# We're using the base environment but we're passing the prod
|
|
|
|
# environment as an url arg to salt://
|
2013-11-06 23:36:40 +00:00
|
|
|
ret = self.run_state(
|
|
|
|
'pip.installed', name='', bin_env=venv_dir,
|
|
|
|
requirements='salt://prod-env-requirements.txt?saltenv=prod'
|
|
|
|
)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
self.assertInSaltComment(
|
2015-01-05 22:36:45 +00:00
|
|
|
'Requirements were already installed.',
|
|
|
|
ret
|
2013-11-06 23:36:40 +00:00
|
|
|
)
|
2013-11-02 22:40:09 +00:00
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2013-11-02 22:40:09 +00:00
|
|
|
if os.path.isfile(requirements_file):
|
|
|
|
os.unlink(requirements_file)
|
|
|
|
|
2015-04-05 00:00:08 +00:00
|
|
|
def test_22359_pip_installed_unless_does_not_trigger_warnings(self):
|
|
|
|
# This test case should be moved to a format_call unit test specific to
|
|
|
|
# the state internal keywords
|
2018-04-25 16:01:52 +00:00
|
|
|
venv_dir = os.path.join(RUNTIME_VARS.TMP, 'pip-installed-unless')
|
2015-04-05 00:00:08 +00:00
|
|
|
venv_create = self.run_function('virtualenv.create', [venv_dir])
|
|
|
|
if venv_create['retcode'] > 0:
|
|
|
|
self.skipTest(
|
|
|
|
'Failed to create testcase virtual environment: {0}'.format(
|
|
|
|
venv_create
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-04-25 16:01:52 +00:00
|
|
|
false_cmd = '/bin/false'
|
2018-05-07 17:36:47 +00:00
|
|
|
if salt.utils.platform.is_windows():
|
2018-04-25 16:01:52 +00:00
|
|
|
false_cmd = 'exit 1 >nul'
|
2015-04-05 00:00:08 +00:00
|
|
|
try:
|
|
|
|
ret = self.run_state(
|
2018-04-25 16:01:52 +00:00
|
|
|
'pip.installed', name='pep8', bin_env=venv_dir, unless=false_cmd
|
2015-04-05 00:00:08 +00:00
|
|
|
)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
2017-02-21 18:15:52 +00:00
|
|
|
self.assertNotIn('warnings', next(six.itervalues(ret)))
|
2015-04-05 00:00:08 +00:00
|
|
|
finally:
|
|
|
|
if os.path.isdir(venv_dir):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(venv_dir, ignore_errors=True)
|
2018-02-28 07:16:54 +00:00
|
|
|
|
2018-03-15 18:06:53 +00:00
|
|
|
@skipIf(sys.version_info[:2] >= (3, 6), 'Old version of virtualenv too old for python3.6')
|
2018-05-07 17:36:47 +00:00
|
|
|
@skipIf(salt.utils.platform.is_windows(), "Carbon does not install in Windows")
|
2018-02-28 07:16:54 +00:00
|
|
|
def test_46127_pip_env_vars(self):
|
|
|
|
'''
|
|
|
|
Test that checks if env_vars passed to pip.installed are also passed
|
|
|
|
to pip.freeze while checking for existing installations
|
|
|
|
'''
|
|
|
|
# This issue is most easily checked while installing carbon
|
|
|
|
# Much of the code here comes from the test_weird_install function above
|
|
|
|
ographite = '/opt/graphite'
|
|
|
|
if os.path.isdir(ographite):
|
|
|
|
self.skipTest(
|
|
|
|
'You already have \'{0}\'. This test would overwrite this '
|
|
|
|
'directory'.format(ographite)
|
|
|
|
)
|
|
|
|
try:
|
|
|
|
os.makedirs(ographite)
|
|
|
|
except OSError as err:
|
|
|
|
if err.errno == errno.EACCES:
|
|
|
|
# Permission denied
|
|
|
|
self.skipTest(
|
|
|
|
'You don\'t have the required permissions to run this test'
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(ographite):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(ographite, ignore_errors=True)
|
2018-02-28 07:16:54 +00:00
|
|
|
|
|
|
|
venv_dir = os.path.join(RUNTIME_VARS.TMP, 'issue-46127-pip-env-vars')
|
|
|
|
try:
|
|
|
|
# We may be able to remove this, I had to add it because the custom
|
|
|
|
# modules from the test suite weren't available in the jinja
|
|
|
|
# context when running the call to state.sls that comes after.
|
|
|
|
self.run_function('saltutil.sync_modules')
|
|
|
|
# Since we don't have the virtualenv created, pip.installed will
|
2018-04-25 16:01:52 +00:00
|
|
|
# throw an error.
|
2018-02-28 07:16:54 +00:00
|
|
|
ret = self.run_function(
|
|
|
|
'state.sls', mods='issue-46127-pip-env-vars'
|
|
|
|
)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
for key in six.iterkeys(ret):
|
|
|
|
self.assertTrue(ret[key]['result'])
|
2018-02-28 10:55:31 +00:00
|
|
|
if ret[key]['name'] != 'carbon < 1.3':
|
2018-02-28 07:16:54 +00:00
|
|
|
continue
|
|
|
|
self.assertEqual(
|
|
|
|
ret[key]['comment'],
|
|
|
|
'All packages were successfully installed'
|
|
|
|
)
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception('Expected state did not run')
|
|
|
|
# Run the state again. Now the already installed message should
|
|
|
|
# appear
|
|
|
|
ret = self.run_function(
|
|
|
|
'state.sls', mods='issue-46127-pip-env-vars'
|
|
|
|
)
|
|
|
|
self.assertSaltTrueReturn(ret)
|
|
|
|
# We cannot use assertInSaltComment here because we need to skip
|
|
|
|
# some of the state return parts
|
|
|
|
for key in six.iterkeys(ret):
|
|
|
|
self.assertTrue(ret[key]['result'])
|
|
|
|
# As we are re-running the formula, some states will not be run
|
|
|
|
# and "name" may or may not be present, so we use .get() pattern
|
2018-02-28 10:55:31 +00:00
|
|
|
if ret[key].get('name', '') != 'carbon < 1.3':
|
2018-02-28 07:16:54 +00:00
|
|
|
continue
|
|
|
|
self.assertEqual(
|
|
|
|
ret[key]['comment'],
|
2018-02-28 10:55:31 +00:00
|
|
|
('Python package carbon < 1.3 was already installed\n'
|
2018-04-21 11:08:08 +00:00
|
|
|
'All specified packages are already installed'))
|
2018-02-28 07:16:54 +00:00
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception('Expected state did not run')
|
|
|
|
finally:
|
|
|
|
if os.path.isdir(ographite):
|
2018-04-25 16:01:52 +00:00
|
|
|
shutil.rmtree(ographite, ignore_errors=True)
|
2018-02-28 07:16:54 +00:00
|
|
|
if os.path.isdir(venv_dir):
|
|
|
|
shutil.rmtree(venv_dir)
|