From a5d406a5456e65b98cee699631f97a796d004190 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Fri, 4 Dec 2015 02:41:43 +0000 Subject: [PATCH] Add tests for extra `envs` in `PYENV_ROOT` --- test/envs.bats | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/envs.bats diff --git a/test/envs.bats b/test/envs.bats new file mode 100644 index 0000000..4da2a75 --- /dev/null +++ b/test/envs.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats + +load test_helper + +setup() { + export PYENV_ROOT="${TMP}/envs/pyenv" +} + +stub_pyenv() { + stub pyenv-prefix " : echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'" + stub pyenv-hooks "virtualenv : echo" + stub pyenv-rehash " : echo rehashed" +} + +unstub_pyenv() { + unstub pyenv-prefix + unstub pyenv-hooks + unstub pyenv-rehash +} + +@test "path should be handled properly even if there is 'envs' in PYENV_ROOT" { + export PYENV_VERSION="3.4.1" + setup_pyvenv "3.4.1" + stub_pyenv "${PYENV_VERSION}" + stub pyenv-version-name "echo '${PYENV_VERSION}'" + stub pyenv-prefix " : echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'" + stub pyenv-virtualenv-prefix " : false" + stub pyenv-exec "pyvenv * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";mkdir -p \${PYENV_ROOT}/versions/3.4.1/envs/venv/bin" + stub pyenv-exec "python -s -m ensurepip : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\";touch \${PYENV_ROOT}/versions/3.4.1/envs/venv/bin/pip" + + run pyenv-virtualenv venv + + assert_success + assert_output <