No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

115 líneas
2.1 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. create_version() {
  4. mkdir -p "${PYENV_ROOT}/versions/$1"
  5. }
  6. setup() {
  7. mkdir -p "$PYENV_TEST_DIR"
  8. cd "$PYENV_TEST_DIR"
  9. }
  10. stub_system_python() {
  11. local stub="${PYENV_TEST_DIR}/bin/python"
  12. mkdir -p "$(dirname "$stub")"
  13. touch "$stub" && chmod +x "$stub"
  14. }
  15. @test "no versions installed" {
  16. stub_system_python
  17. assert [ ! -d "${PYENV_ROOT}/versions" ]
  18. run pyenv-versions
  19. assert_success "* system (set by ${PYENV_ROOT}/version)"
  20. }
  21. @test "bare output no versions installed" {
  22. assert [ ! -d "${PYENV_ROOT}/versions" ]
  23. run pyenv-versions --bare
  24. assert_success ""
  25. }
  26. @test "single version installed" {
  27. stub_system_python
  28. create_version "3.3"
  29. run pyenv-versions
  30. assert_success
  31. assert_output <<OUT
  32. * system (set by ${PYENV_ROOT}/version)
  33. 3.3
  34. OUT
  35. }
  36. @test "single version bare" {
  37. create_version "3.3"
  38. run pyenv-versions --bare
  39. assert_success "3.3"
  40. }
  41. @test "multiple versions" {
  42. stub_system_python
  43. create_version "2.7.6"
  44. create_version "3.3.3"
  45. create_version "3.4.0"
  46. run pyenv-versions
  47. assert_success
  48. assert_output <<OUT
  49. * system (set by ${PYENV_ROOT}/version)
  50. 2.7.6
  51. 3.3.3
  52. 3.4.0
  53. OUT
  54. }
  55. @test "indicates current version" {
  56. stub_system_python
  57. create_version "3.3.3"
  58. create_version "3.4.0"
  59. PYENV_VERSION=3.3.3 run pyenv-versions
  60. assert_success
  61. assert_output <<OUT
  62. system
  63. * 3.3.3 (set by PYENV_VERSION environment variable)
  64. 3.4.0
  65. OUT
  66. }
  67. @test "bare doesn't indicate current version" {
  68. create_version "3.3.3"
  69. create_version "3.4.0"
  70. PYENV_VERSION=3.3.3 run pyenv-versions --bare
  71. assert_success
  72. assert_output <<OUT
  73. 3.3.3
  74. 3.4.0
  75. OUT
  76. }
  77. @test "globally selected version" {
  78. stub_system_python
  79. create_version "3.3.3"
  80. create_version "3.4.0"
  81. cat > "${PYENV_ROOT}/version" <<<"3.3.3"
  82. run pyenv-versions
  83. assert_success
  84. assert_output <<OUT
  85. system
  86. * 3.3.3 (set by ${PYENV_ROOT}/version)
  87. 3.4.0
  88. OUT
  89. }
  90. @test "per-project version" {
  91. stub_system_python
  92. create_version "3.3.3"
  93. create_version "3.4.0"
  94. cat > ".python-version" <<<"3.3.3"
  95. run pyenv-versions
  96. assert_success
  97. assert_output <<OUT
  98. system
  99. * 3.3.3 (set by ${PYENV_TEST_DIR}/.python-version)
  100. 3.4.0
  101. OUT
  102. }