#!/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_lib() { stub python-build "--lib : $BATS_TEST_DIRNAME/../bin/python-build --lib" "$@" } stub_python_build_no_latest() { stub python-build "${@:-echo python-build \"\$@\"}" } stub_python_build() { stub_python_build_no_latest "$@" stub pyenv-latest '-f -k * : shift 2; echo "$@"' } @test "install a single version" { stub_python_build_lib stub_python_build run pyenv-install 3.4.2 assert_success "python-build 3.4.2 ${PYENV_ROOT}/versions/3.4.2" unstub python-build } @test "install multiple versions" { stub_python_build_lib stub_python_build stub_python_build run pyenv-install 3.4.1 3.4.2 assert_success assert_output <&2 && exit 2' stub_python_build "--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 <