Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

65 righe
1.4 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. @test "no version selected" {
  11. assert [ ! -d "${PYENV_ROOT}/versions" ]
  12. run pyenv-version-name
  13. assert_success "system"
  14. }
  15. @test "system version is not checked for existance" {
  16. PYENV_VERSION=system run pyenv-version-name
  17. assert_success "system"
  18. }
  19. @test "PYENV_VERSION has precedence over local" {
  20. create_version "2.7.6"
  21. create_version "3.3.3"
  22. cat > ".python-version" <<<"2.7.6"
  23. run pyenv-version-name
  24. assert_success "2.7.6"
  25. PYENV_VERSION=3.3.3 run pyenv-version-name
  26. assert_success "3.3.3"
  27. }
  28. @test "local file has precedence over global" {
  29. create_version "2.7.6"
  30. create_version "3.3.3"
  31. cat > "${PYENV_ROOT}/version" <<<"2.7.6"
  32. run pyenv-version-name
  33. assert_success "2.7.6"
  34. cat > ".python-version" <<<"3.3.3"
  35. run pyenv-version-name
  36. assert_success "3.3.3"
  37. }
  38. @test "missing version" {
  39. PYENV_VERSION=1.2 run pyenv-version-name
  40. assert_failure "pyenv: version \`1.2' is not installed"
  41. }
  42. @test "version with prefix in name" {
  43. create_version "2.7.6"
  44. cat > ".python-version" <<<"python-2.7.6"
  45. run pyenv-version-name
  46. assert_success
  47. assert_output <<OUT
  48. warning: ignoring extraneous \`python-' prefix in version \`python-2.7.6'
  49. (set by ${PWD}/.python-version)
  50. 2.7.6
  51. OUT
  52. }