#!/usr/bin/env bats load test_helper export PYENV_ROOT="${TMP}/pyenv" setup() { stub pyenv-hooks 'install : true' stub pyenv-rehash 'true' } stub_python_build() { stub python-build "--lib : $BATS_TEST_DIRNAME/../bin/python-build --lib" "$@" } @test "install proper" { stub_python_build 'echo python-build "$@"' run pyenv-install 3.4.2 assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2" unstub python-build unstub pyenv-hooks unstub pyenv-rehash } @test "install pyenv local version by default" { stub_python_build 'echo python-build "$1"' stub pyenv-local 'echo 3.4.2' run pyenv-install assert_success "python-build 3.4.2" unstub python-build unstub pyenv-local } @test "list available versions" { stub_python_build \ "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'" run pyenv-install --list assert_success assert_output <&2 && exit 2' \ "--definitions : echo 2.6.9 2.7.9-rc1 2.7.9-rc2 3.4.2 | tr ' ' $'\\n'" run pyenv-install 2.7.9 assert_failure assert_output <&2 && exit 2' \ "--definitions : true" run pyenv-install 1.9.3 assert_failure assert_output <