You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 rivejä
1.3 KiB

  1. #!/usr/bin/env bats
  2. load test_helper
  3. setup() {
  4. mkdir -p "${PYENV_TEST_DIR}/myproject"
  5. cd "${PYENV_TEST_DIR}/myproject"
  6. }
  7. @test "no version" {
  8. assert [ ! -e "${PWD}/.python-version" ]
  9. run pyenv-local
  10. assert_failure "pyenv: no local version configured for this directory"
  11. }
  12. @test "local version" {
  13. echo "1.2.3" > .python-version
  14. run pyenv-local
  15. assert_success "1.2.3"
  16. }
  17. @test "discovers version file in parent directory" {
  18. echo "1.2.3" > .python-version
  19. mkdir -p "subdir" && cd "subdir"
  20. run pyenv-local
  21. assert_success "1.2.3"
  22. }
  23. @test "ignores PYENV_DIR" {
  24. echo "1.2.3" > .python-version
  25. mkdir -p "$HOME"
  26. echo "3.4-home" > "${HOME}/.python-version"
  27. PYENV_DIR="$HOME" run pyenv-local
  28. assert_success "1.2.3"
  29. }
  30. @test "sets local version" {
  31. mkdir -p "${PYENV_ROOT}/versions/1.2.3"
  32. run pyenv-local 1.2.3
  33. assert_success ""
  34. assert [ "$(cat .python-version)" = "1.2.3" ]
  35. }
  36. @test "changes local version" {
  37. echo "1.0-pre" > .python-version
  38. mkdir -p "${PYENV_ROOT}/versions/1.2.3"
  39. run pyenv-local
  40. assert_success "1.0-pre"
  41. run pyenv-local 1.2.3
  42. assert_success ""
  43. assert [ "$(cat .python-version)" = "1.2.3" ]
  44. }
  45. @test "unsets local version" {
  46. touch .python-version
  47. run pyenv-local --unset
  48. assert_success ""
  49. assert [ ! -e .python-version ]
  50. }