403Webshell
Server IP : 103.175.220.74  /  Your IP : 216.73.216.151
Web Server : nginx/1.18.0
System : Linux p-floo-wj1-db 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : deploy ( 1003)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/deploy/.pyenv/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/deploy/.pyenv/test/versions.bats
#!/usr/bin/env bats

load test_helper

create_version() {
  mkdir -p "${PYENV_ROOT}/versions/$1"
}

create_alias() {
  mkdir -p "${PYENV_ROOT}/versions"
  ln -s "$2" "${PYENV_ROOT}/versions/$1"
}

create_external_version() {
  mkdir -p "$PYENV_TEST_DIR/${1:?}"
  create_alias "${1:?}" "$PYENV_TEST_DIR/${1:?}"
}

_setup() {
  mkdir -p "$PYENV_TEST_DIR"
  cd "$PYENV_TEST_DIR"
}

stub_system_python() {
  local stub="${PYENV_TEST_DIR}/bin/python"
  mkdir -p "$(dirname "$stub")"
  touch "$stub" && chmod +x "$stub"
}

@test "no versions installed" {
  stub_system_python
  assert [ ! -d "${PYENV_ROOT}/versions" ]
  run pyenv-versions
  assert_success "* system (set by ${PYENV_ROOT}/version)"
}

@test "not even system python available" {
  PATH="$(path_without python python2 python3)" run pyenv-versions
  assert_failure
  assert_output "Warning: no Python detected on the system"
}

@test "bare output no versions installed" {
  assert [ ! -d "${PYENV_ROOT}/versions" ]
  run pyenv-versions --bare
  assert_success ""
}

@test "single version installed" {
  stub_system_python
  create_version "3.3"
  run pyenv-versions
  assert_success
  assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
  3.3
OUT
}

@test "single version bare" {
  create_version "3.3"
  run pyenv-versions --bare
  assert_success "3.3"
}

@test "multiple versions and envs" {
  stub_system_python
  create_version "2.7.6"
  create_version "3.4.0"
  create_version "3.4.0/envs/foo"
  create_version "3.4.0/envs/bar"
  create_version "3.5.2"
  run pyenv-versions
  assert_success
  assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
  2.7.6
  3.4.0
  3.4.0/envs/bar
  3.4.0/envs/foo
  3.5.2
OUT
}

@test "skips envs with --skip-envs" {
  create_version "3.3.3"
  create_version "3.4.0"
  create_version "3.4.0/envs/foo"
  create_version "3.4.0/envs/bar"
  create_version "3.5.0"

  run pyenv-versions --skip-envs
    assert_success <<OUT
* system (set by ${PYENV_ROOT}/version)
  3.3.3
  3.4.0
  3.5.0
OUT
}

@test "indicates current version" {
  stub_system_python
  create_version "3.3.3"
  create_version "3.4.0"
  PYENV_VERSION=3.3.3 run pyenv-versions
  assert_success
  assert_output <<OUT
  system
* 3.3.3 (set by PYENV_VERSION environment variable)
  3.4.0
OUT
}

@test "bare doesn't indicate current version" {
  create_version "3.3.3"
  create_version "3.4.0"
  PYENV_VERSION=3.3.3 run pyenv-versions --bare
  assert_success
  assert_output <<OUT
3.3.3
3.4.0
OUT
}

@test "globally selected version" {
  stub_system_python
  create_version "3.3.3"
  create_version "3.4.0"
  cat > "${PYENV_ROOT}/version" <<<"3.3.3"
  run pyenv-versions
  assert_success
  assert_output <<OUT
  system
* 3.3.3 (set by ${PYENV_ROOT}/version)
  3.4.0
OUT
}

@test "per-project version" {
  stub_system_python
  create_version "3.3.3"
  create_version "3.4.0"
  cat > ".python-version" <<<"3.3.3"
  run pyenv-versions
  assert_success
  assert_output <<OUT
  system
* 3.3.3 (set by ${PYENV_TEST_DIR}/.python-version)
  3.4.0
OUT
}

@test "ignores non-directories under versions" {
  create_version "3.3"
  touch "${PYENV_ROOT}/versions/hello"

  run pyenv-versions --bare
  assert_success "3.3"
}

@test "lists symlinks under versions" {
  create_version "2.7.8"
  create_alias "2.7" "2.7.8"

  run pyenv-versions --bare
  assert_success
  assert_output <<OUT
2.7
2.7.8
OUT
}

@test "doesn't list symlink aliases when --skip-aliases" {
  create_version "1.8.7"
  create_alias "1.8" "1.8.7"
  create_external_version "moo"

  run pyenv-versions --bare --skip-aliases
  assert_success

  assert_output <<OUT
1.8.7
moo
OUT
}

@test "--executables lists executables everywhere and overrides other switches" {
  create_alt_executable_in_version "3.5.0" "python"
  create_alt_executable_in_version "3.5.0" "python1"
  create_alt_executable_in_version "3.6.0" "python"
  create_alt_executable_in_version "3.5.0/envs/foo" "python_foo"
  create_alt_executable_in_version "3.6.0/envs/bar" "python_bar"
  create_alias "bar" "3.6.0/envs/bar"
  create_external_version "moo"
  create_alt_executable_in_version "moo" "moopython"

  run pyenv-versions --skip-aliases --skip-envs --executables
  assert_success
  #The sort order does not matter for this functionality. However,
  #MacOS 15 `sort` sorts differently that Linux's due to a different LC_COLLATE definition for en-US:
  #https://unix.stackexchange.com/questions/362728/why-does-gnu-sort-sort-differently-on-my-osx-machine-and-linux-machine
  #So to get a match, we have to check against the same order that the local `sort` produces
  sort <<OUT | assert_output
moopython
python
python1
python_bar
python_foo
OUT
}

@test "lists dot directories under versions" {
  create_version ".venv"

  run pyenv-versions --bare
  assert_success ".venv"
}

@test "sort supports version sorting" {
  create_version "1.9.0"
  create_version "1.53.0"
  create_version "1.218.0"
  create_path_executable sort <<SH
#!$BASH
cat >/dev/null
if [ "\$1" == "--version-sort" ]; then
  echo "${PYENV_ROOT}/versions/1.9.0"
  echo "${PYENV_ROOT}/versions/1.53.0"
  echo "${PYENV_ROOT}/versions/1.218.0"
else exit 1
fi
SH

  run pyenv-versions --bare
  assert_success
  assert_output <<OUT
1.9.0
1.53.0
1.218.0
OUT
}

@test "sort doesn't support version sorting" {
  create_version "1.9.0"
  create_version "1.53.0"
  create_version "1.218.0"
  create_path_executable sort <<SH
#!$BASH
exit 1
SH

  run pyenv-versions --bare
  assert_success
  assert_output <<OUT
1.218.0
1.53.0
1.9.0
OUT
}

@test "non-bare output shows symlink contents" {
  stub_system_python
  create_version "1.9.0"
  create_alias "link" "1.9.0"

  run pyenv-versions
  assert_success
  assert_output <<OUT
* system (set by ${PYENV_ROOT}/version)
  1.9.0
  link --> 1.9.0
OUT
}

Youez - 2016 - github.com/yon3zu
LinuXploit