mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Add test for VENV_PIP_TARGET environment variable
This commit is contained in:
parent
aaafe75759
commit
15c9e069ac
1 changed files with 31 additions and 0 deletions
|
@ -1774,3 +1774,34 @@ def test_when_version_is_called_with_a_user_it_should_be_passed_to_undelying_run
|
|||
cwd=None,
|
||||
python_shell=False,
|
||||
)
|
||||
|
||||
|
||||
def test_install_target_from_VENV_PIP_TARGET_in_resulting_command():
|
||||
pkg = "pep8"
|
||||
target = "/tmp/foo"
|
||||
target_env = "/tmp/bar"
|
||||
mock = MagicMock(return_value={"retcode": 0, "stdout": ""})
|
||||
environment = os.environ.copy()
|
||||
environment["VENV_PIP_TARGET"] = target_env
|
||||
with patch.dict(pip.__salt__, {"cmd.run_all": mock}), patch.object(
|
||||
os, "environ", environment
|
||||
):
|
||||
pip.install(pkg)
|
||||
expected = [sys.executable, "-m", "pip", "install", "--target", target_env, pkg]
|
||||
mock.assert_called_with(
|
||||
expected,
|
||||
saltenv="base",
|
||||
runas=None,
|
||||
use_vt=False,
|
||||
python_shell=False,
|
||||
)
|
||||
mock.reset_mock()
|
||||
pip.install(pkg, target=target)
|
||||
expected = [sys.executable, "-m", "pip", "install", "--target", target, pkg]
|
||||
mock.assert_called_with(
|
||||
expected,
|
||||
saltenv="base",
|
||||
runas=None,
|
||||
use_vt=False,
|
||||
python_shell=False,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue