Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

101 linhas
3.0 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. setup() {
  4. export PYENV_ROOT="${TMP}/pyenv"
  5. export PYENV_VERSION="2.7.8"
  6. create_executable "${PYENV_VERSION}" "virtualenv"
  7. remove_executable "${PYENV_VERSION}" "pyvenv"
  8. stub pyenv-prefix "echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'"
  9. stub pyenv-prefix "echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'"
  10. stub pyenv-prefix "echo '${PYENV_ROOT}/versions/${PYENV_VERSION}'"
  11. stub pyenv-hooks "virtualenv : echo"
  12. stub pyenv-rehash " : true"
  13. stub pyenv-version-name "echo \${PYENV_VERSION}"
  14. stub curl true
  15. }
  16. teardown() {
  17. unstub curl
  18. unstub pyenv-version-name
  19. unstub pyenv-prefix
  20. unstub pyenv-hooks
  21. unstub pyenv-rehash
  22. rm -fr "$TMP"/*
  23. }
  24. @test "resolve python executable from enabled version" {
  25. remove_executable "2.7.7" "python2.7"
  26. create_executable "2.7.8" "python2.7"
  27. remove_executable "2.7.9" "python2.7"
  28. stub pyenv-exec "virtualenv --verbose * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\""
  29. stub pyenv-exec "python -s -m ensurepip : true"
  30. stub pyenv-which "python2.7 : echo ${PYENV_ROOT}/versions/2.7.8/bin/python2.7"
  31. run pyenv-virtualenv --verbose --python=python2.7 venv
  32. assert_output <<OUT
  33. PYENV_VERSION=2.7.8 virtualenv --verbose --python=${PYENV_ROOT}/versions/2.7.8/bin/python2.7 ${PYENV_ROOT}/versions/2.7.8/envs/venv
  34. OUT
  35. assert_success
  36. unstub pyenv-which
  37. unstub pyenv-exec
  38. remove_executable "2.7.7" "python2.7"
  39. remove_executable "2.7.8" "python2.7"
  40. remove_executable "2.7.9" "python2.7"
  41. }
  42. @test "resolve python executable from other versions" {
  43. remove_executable "2.7.7" "python2.7"
  44. remove_executable "2.7.8" "python2.7"
  45. create_executable "2.7.9" "python2.7"
  46. stub pyenv-exec "virtualenv --verbose * : echo PYENV_VERSION=\${PYENV_VERSION} \"\$@\""
  47. stub pyenv-exec "python -s -m ensurepip : true"
  48. stub pyenv-which "python2.7 : false"
  49. stub pyenv-whence "python2.7 : echo 2.7.7; echo 2.7.8; echo 2.7.9"
  50. stub pyenv-which "python2.7 : echo ${PYENV_ROOT}/versions/2.7.9/bin/python2.7"
  51. run pyenv-virtualenv --verbose --python=python2.7 venv
  52. assert_output <<OUT
  53. PYENV_VERSION=2.7.8 virtualenv --verbose --python=${PYENV_ROOT}/versions/2.7.9/bin/python2.7 ${PYENV_ROOT}/versions/2.7.8/envs/venv
  54. OUT
  55. assert_success
  56. unstub pyenv-which
  57. unstub pyenv-whence
  58. unstub pyenv-exec
  59. remove_executable "2.7.7" "python2.7"
  60. remove_executable "2.7.8" "python2.7"
  61. remove_executable "2.7.9" "python2.7"
  62. }
  63. @test "cannot resolve python executable" {
  64. remove_executable "2.7.7" "python2.7"
  65. remove_executable "2.7.8" "python2.7"
  66. remove_executable "2.7.9" "python2.7"
  67. stub pyenv-which "python2.7 : false"
  68. stub pyenv-whence "python2.7 : false"
  69. stub pyenv-which "python2.7 : false"
  70. run pyenv-virtualenv --verbose --python=python2.7 venv
  71. assert_output <<OUT
  72. pyenv-virtualenv: \`python2.7' is not installed in pyenv.
  73. OUT
  74. assert_failure
  75. unstub pyenv-which
  76. unstub pyenv-whence
  77. remove_executable "2.7.7" "python2.7"
  78. remove_executable "2.7.8" "python2.7"
  79. remove_executable "2.7.9" "python2.7"
  80. }