mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix integration.modules.test_pip
Removes references to `no_chown`. It hasn't been in use since 2015.8 Removes usage of user in pip calls. The user is defined as the current user which is the default anyway and it's causing tests not to run in Windows because Windows requires a password Removes the pwd import since it is no longer needed
This commit is contained in:
parent
57d98224d4
commit
22ac81df63
4 changed files with 56 additions and 59 deletions
|
@ -417,7 +417,6 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
global_options=None,
|
||||
install_options=None,
|
||||
user=None,
|
||||
no_chown=False,
|
||||
cwd=None,
|
||||
pre_releases=False,
|
||||
cert=None,
|
||||
|
@ -431,7 +430,8 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
trusted_host=None,
|
||||
no_cache_dir=False,
|
||||
cache_dir=None,
|
||||
no_binary=None):
|
||||
no_binary=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Install packages with pip
|
||||
|
||||
|
@ -553,10 +553,6 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
user
|
||||
The user under which to run pip
|
||||
|
||||
no_chown
|
||||
When user is given, do not attempt to copy and chown a requirements
|
||||
file
|
||||
|
||||
cwd
|
||||
Current working directory to run pip from
|
||||
|
||||
|
@ -617,6 +613,12 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
|
|||
editable=git+https://github.com/worldcompany/djangoembed.git#egg=djangoembed upgrade=True no_deps=True
|
||||
|
||||
'''
|
||||
if 'no_chown' in kwargs:
|
||||
salt.utils.warn_until(
|
||||
'Flourine',
|
||||
'The no_chown argument has been deprecated and is no longer used. '
|
||||
'Its functionality was removed in Boron.')
|
||||
kwargs.pop('no_chown')
|
||||
cmd = _get_pip_bin(bin_env)
|
||||
cmd.append('install')
|
||||
|
||||
|
@ -915,7 +917,6 @@ def uninstall(pkgs=None,
|
|||
proxy=None,
|
||||
timeout=None,
|
||||
user=None,
|
||||
no_chown=False,
|
||||
cwd=None,
|
||||
saltenv='base',
|
||||
use_vt=False):
|
||||
|
@ -948,11 +949,6 @@ def uninstall(pkgs=None,
|
|||
Set the socket timeout (default 15 seconds)
|
||||
user
|
||||
The user under which to run pip
|
||||
no_chown
|
||||
When user is given, do not attempt to copy and chown
|
||||
a requirements file (needed if the requirements file refers to other
|
||||
files via relative paths, as the copy-and-chown procedure does not
|
||||
account for such files)
|
||||
cwd
|
||||
Current working directory to run pip from
|
||||
use_vt
|
||||
|
|
|
@ -308,7 +308,6 @@ def installed(name,
|
|||
install_options=None,
|
||||
global_options=None,
|
||||
user=None,
|
||||
no_chown=False,
|
||||
cwd=None,
|
||||
pre_releases=False,
|
||||
cert=None,
|
||||
|
@ -321,7 +320,8 @@ def installed(name,
|
|||
trusted_host=None,
|
||||
no_cache_dir=False,
|
||||
cache_dir=None,
|
||||
no_binary=None):
|
||||
no_binary=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Make sure the package is installed
|
||||
|
||||
|
@ -443,10 +443,6 @@ def installed(name,
|
|||
no_install
|
||||
Download and unpack all packages, but don't actually install them
|
||||
|
||||
no_chown
|
||||
When user is given, do not attempt to copy and chown
|
||||
a requirements file
|
||||
|
||||
no_cache_dir:
|
||||
Disable the cache.
|
||||
|
||||
|
@ -589,6 +585,12 @@ def installed(name,
|
|||
|
||||
.. _`virtualenv`: http://www.virtualenv.org/en/latest/
|
||||
'''
|
||||
if 'no_chown' in kwargs:
|
||||
salt.utils.warn_until(
|
||||
'Flourine',
|
||||
'The no_chown argument has been deprecated and is no longer used. '
|
||||
'Its functionality was removed in Boron.')
|
||||
kwargs.pop('no_chown')
|
||||
|
||||
if pip_bin and not bin_env:
|
||||
bin_env = pip_bin
|
||||
|
@ -801,7 +803,6 @@ def installed(name,
|
|||
install_options=install_options,
|
||||
global_options=global_options,
|
||||
user=user,
|
||||
no_chown=no_chown,
|
||||
cwd=cwd,
|
||||
pre_releases=pre_releases,
|
||||
cert=cert,
|
||||
|
|
|
@ -39,7 +39,6 @@ def managed(name,
|
|||
never_download=None,
|
||||
prompt=None,
|
||||
user=None,
|
||||
no_chown=False,
|
||||
cwd=None,
|
||||
index_url=None,
|
||||
extra_index_url=None,
|
||||
|
@ -58,7 +57,8 @@ def managed(name,
|
|||
pip_no_cache_dir=False,
|
||||
pip_cache_dir=None,
|
||||
process_dependency_links=False,
|
||||
no_binary=None):
|
||||
no_binary=None,
|
||||
**kwargs):
|
||||
'''
|
||||
Create a virtualenv and optionally manage it with pip
|
||||
|
||||
|
@ -78,11 +78,6 @@ def managed(name,
|
|||
user: None
|
||||
The user under which to run virtualenv and pip.
|
||||
|
||||
no_chown: False
|
||||
When user is given, do not attempt to copy and chown a requirements file
|
||||
(needed if the requirements file refers to other files via relative
|
||||
paths, as the copy-and-chown procedure does not account for such files)
|
||||
|
||||
cwd: None
|
||||
Path to the working directory where `pip install` is executed.
|
||||
|
||||
|
@ -133,6 +128,13 @@ def managed(name,
|
|||
- env_vars:
|
||||
PATH_VAR: '/usr/local/bin/'
|
||||
'''
|
||||
if 'no_chown' in kwargs:
|
||||
salt.utils.warn_until(
|
||||
'Flourine',
|
||||
'The no_chown argument has been deprecated and is no longer used. '
|
||||
'Its functionality was removed in Boron.')
|
||||
kwargs.pop('no_chown')
|
||||
|
||||
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
|
||||
|
||||
if 'virtualenv.create' not in __salt__:
|
||||
|
@ -305,7 +307,6 @@ def managed(name,
|
|||
extra_index_url=extra_index_url,
|
||||
download=pip_download,
|
||||
download_cache=pip_download_cache,
|
||||
no_chown=no_chown,
|
||||
pre_releases=pre_releases,
|
||||
exists_action=pip_exists_action,
|
||||
ignore_installed=pip_ignore_installed,
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import os
|
||||
import pwd
|
||||
import shutil
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
@ -73,23 +73,34 @@ class PipModuleTest(ModuleCase):
|
|||
|
||||
# Let's remove the pip binary
|
||||
pip_bin = os.path.join(self.venv_dir, 'bin', 'pip')
|
||||
py_dir = 'python{0}.{1}'.format(*sys.version_info[:2])
|
||||
site_dir = os.path.join(self.venv_dir, 'lib', py_dir, 'site-packages')
|
||||
if salt.utils.is_windows():
|
||||
pip_bin = os.path.join(self.venv_dir, 'Scripts', 'pip.exe')
|
||||
site_dir = os.path.join(self.venv_dir, 'lib', 'site-packages')
|
||||
if not os.path.isfile(pip_bin):
|
||||
self.skipTest(
|
||||
'Failed to find the pip binary to the test virtualenv'
|
||||
)
|
||||
os.remove(pip_bin)
|
||||
|
||||
# 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'))
|
||||
|
||||
# Let's run a pip depending functions
|
||||
for func in ('pip.freeze', 'pip.list'):
|
||||
ret = self.run_function(func, bin_env=self.venv_dir)
|
||||
self.assertIn(
|
||||
'Command required for \'{0}\' not found: '
|
||||
'Could not find a `pip` binary in virtualenv'.format(func),
|
||||
'Could not find a `pip` binary'.format(func),
|
||||
ret
|
||||
)
|
||||
|
||||
@skip_if_not_root
|
||||
def test_requirements_as_list_of_chains__sans_no_chown__cwd_set__absolute_file_path(self):
|
||||
def test_requirements_as_list_of_chains__cwd_set__absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -108,11 +119,10 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2b_filename, 'w') as f:
|
||||
f.write('pep8\n')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
requirements_list = [req1_filename, req2_filename]
|
||||
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=requirements_list, user=this_user,
|
||||
'pip.install', requirements=requirements_list,
|
||||
bin_env=self.venv_dir, cwd=self.venv_dir
|
||||
)
|
||||
try:
|
||||
|
@ -127,7 +137,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_requirements_as_list_of_chains__sans_no_chown__cwd_not_set__absolute_file_path(self):
|
||||
def test_requirements_as_list_of_chains__cwd_not_set__absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -146,12 +156,10 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2b_filename, 'w') as f:
|
||||
f.write('pep8\n')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
requirements_list = [req1_filename, req2_filename]
|
||||
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=requirements_list, user=this_user,
|
||||
bin_env=self.venv_dir
|
||||
'pip.install', requirements=requirements_list, bin_env=self.venv_dir
|
||||
)
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
|
@ -166,7 +174,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_requirements_as_list__sans_no_chown__absolute_file_path(self):
|
||||
def test_requirements_as_list__absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
req1_filename = os.path.join(self.venv_dir, 'requirements.txt')
|
||||
|
@ -177,12 +185,10 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2_filename, 'w') as f:
|
||||
f.write('pep8\n')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
requirements_list = [req1_filename, req2_filename]
|
||||
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=requirements_list, user=this_user,
|
||||
bin_env=self.venv_dir
|
||||
'pip.install', requirements=requirements_list, bin_env=self.venv_dir
|
||||
)
|
||||
|
||||
found = self.pip_successful_install(ret['stdout'])
|
||||
|
@ -197,7 +203,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_requirements_as_list__sans_no_chown__non_absolute_file_path(self):
|
||||
def test_requirements_as_list__non_absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -214,11 +220,10 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2_filepath, 'w') as f:
|
||||
f.write('pep8\n')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
requirements_list = [req1_filename, req2_filename]
|
||||
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=requirements_list, user=this_user,
|
||||
'pip.install', requirements=requirements_list,
|
||||
bin_env=self.venv_dir, cwd=req_cwd
|
||||
)
|
||||
try:
|
||||
|
@ -233,7 +238,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_chained_requirements__sans_no_chown__absolute_file_path(self):
|
||||
def test_chained_requirements__absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -246,10 +251,8 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2_filename, 'w') as f:
|
||||
f.write('pep8')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=req1_filename, user=this_user,
|
||||
bin_env=self.venv_dir
|
||||
'pip.install', requirements=req1_filename, bin_env=self.venv_dir
|
||||
)
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
|
@ -260,7 +263,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_chained_requirements__sans_no_chown__non_absolute_file_path(self):
|
||||
def test_chained_requirements__non_absolute_file_path(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -277,10 +280,9 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2_file, 'w') as f:
|
||||
f.write('pep8')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=req1_filename, user=this_user,
|
||||
no_chown=False, cwd=req_basepath, bin_env=self.venv_dir
|
||||
'pip.install', requirements=req1_filename, cwd=req_basepath,
|
||||
bin_env=self.venv_dir
|
||||
)
|
||||
try:
|
||||
self.assertEqual(ret['retcode'], 0)
|
||||
|
@ -291,7 +293,7 @@ class PipModuleTest(ModuleCase):
|
|||
raise
|
||||
|
||||
@skip_if_not_root
|
||||
def test_issue_4805_nested_requirements_user_no_chown(self):
|
||||
def test_issue_4805_nested_requirements(self):
|
||||
self.run_function('virtualenv.create', [self.venv_dir])
|
||||
|
||||
# Create a requirements file that depends on another one.
|
||||
|
@ -302,11 +304,8 @@ class PipModuleTest(ModuleCase):
|
|||
with salt.utils.fopen(req2_filename, 'w') as f:
|
||||
f.write('pep8')
|
||||
|
||||
this_user = pwd.getpwuid(os.getuid())[0]
|
||||
ret = self.run_function(
|
||||
'pip.install', requirements=req1_filename, user=this_user,
|
||||
no_chown=True, bin_env=self.venv_dir
|
||||
)
|
||||
'pip.install', requirements=req1_filename, bin_env=self.venv_dir)
|
||||
if self._check_download_error(ret['stdout']):
|
||||
self.skipTest('Test skipped due to pip download error')
|
||||
try:
|
||||
|
@ -435,9 +434,9 @@ class PipModuleTest(ModuleCase):
|
|||
def tearDown(self):
|
||||
super(PipModuleTest, self).tearDown()
|
||||
if os.path.isdir(self.venv_test_dir):
|
||||
shutil.rmtree(self.venv_test_dir)
|
||||
shutil.rmtree(self.venv_test_dir, ignore_errors=True)
|
||||
if os.path.isdir(self.pip_temp):
|
||||
shutil.rmtree(self.pip_temp)
|
||||
shutil.rmtree(self.pip_temp, ignore_errors=True)
|
||||
del self.venv_dir
|
||||
del self.venv_test_dir
|
||||
del self.pip_temp
|
||||
|
|
Loading…
Add table
Reference in a new issue