pyenv
The atago project wrote these specs on its own initiative and runs them in its own CI, to exercise atago against a real program. They are not pyenv’s official test suite, and the pyenv project is not affiliated with atago.
Summary #
1 suite · 5 scenarios
Contents #
- pyenv (more than one version at a time) — 5 scenarios
pyenv (more than one version at a time) #
pyenv selects the Python a command runs
under. It keeps its own test suite in Bats, and it shares its ancestry with
rbenv — so this suite deliberately does not repeat what the
rbenv suite already pins. What is here is what pyenv does
differently: a version file that names several versions at once, aliases
that sit beside real versions, and whence, which answers the question
those two raise — which of the selected versions actually provides this
command.
No Python is installed and none is needed: a version is a directory under the root, so each scenario writes a couple of two-line executables and exercises the real resolution rules against them.
Source: test/e2e/thirdparty/pyenv/pyenv.atago.yaml
Scenario: a version file can name several versions, and order decides #
only when pyenv --version succeeds · skipped on Windows
Given #
- Fixture file
root/versions/3.11.9/bin/pythonis created. - Fixture file
root/versions/3.12.4/bin/pythonis created. - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture root/versions/3.11.9/bin/python:
#!/bin/sh
echo "Python 3.11.9"
Fixture root/versions/3.12.4/bin/python:
#!/bin/sh
echo "Python 3.12.4"
When #
pyenv local 3.12.4 3.11.9
pyenv version
pyenv which python
Then #
- after
pyenv local 3.12.4 3.11.9:- exit code is
0 - the step changed exactly created
.python-version, modified nothing, deleted nothing - file
.python-versionequals exact bytes
- exit code is
- after
pyenv version:- exit code is
0 - stdout matches
/(?m)^3\.12\.4 \(set by .*/\.python-version\)$/ - stdout matches
/(?m)^3\.11\.9 \(set by .*/\.python-version\)$/
- exit code is
- after
pyenv which python:- exit code is
0 - stdout matches
//root/versions/3\.12\.4/bin/python\n$/
- exit code is
Scenario: whence answers which of them has the command #
only when pyenv --version succeeds · skipped on Windows
Given #
- Fixture file
root/versions/3.11.9/bin/pythonis created. - Fixture file
root/versions/3.11.9/bin/toxis created. - Fixture file
root/versions/3.12.4/bin/pythonis created. - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture root/versions/3.11.9/bin/python:
#!/bin/sh
echo "Python 3.11.9"
Fixture root/versions/3.11.9/bin/tox:
#!/bin/sh
echo "tox from 3.11.9"
Fixture root/versions/3.12.4/bin/python:
#!/bin/sh
echo "Python 3.12.4"
When #
pyenv whence python
pyenv whence tox
pyenv whence pip
Then #
- after
pyenv whence python:- exit code is
0 - stdout equals an exact value
- exit code is
- after
pyenv whence tox:- exit code is
0 - stdout equals an exact value
- exit code is
- after
pyenv whence pip:- exit code is
1 - stdout is empty
- exit code is
Expected output #
expected stdout:
3.11.9
3.12.4
expected stdout:
3.11.9
Scenario: the shim reaches into whichever selected version has the command #
only when pyenv --version succeeds · skipped on Windows
Given #
- Fixture file
root/versions/3.11.9/bin/pythonis created. - Fixture file
root/versions/3.11.9/bin/toxis created. - Fixture file
root/versions/3.12.4/bin/pythonis created. - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture root/versions/3.11.9/bin/python:
#!/bin/sh
echo "Python 3.11.9"
Fixture root/versions/3.11.9/bin/tox:
#!/bin/sh
echo "tox from 3.11.9"
Fixture root/versions/3.12.4/bin/python:
#!/bin/sh
echo "Python 3.12.4"
When #
pyenv local 3.12.4 3.11.9 && pyenv rehash
PATH="${workdir}/root/shims:$PATH" python
PATH="${workdir}/root/shims:$PATH" tox
Then #
- after
pyenv local 3.12.4 3.11.9 && pyenv rehash:- exit code is
0 - dir
root/shimscontainspython, containstox, has 2 entries
- exit code is
- after
PATH="${workdir}/root/shims:$PATH" python:- exit code is
0 - stdout equals an exact value
- exit code is
- after
PATH="${workdir}/root/shims:$PATH" tox:- exit code is
0 - stdout equals an exact value
- exit code is
Expected output #
expected stdout:
Python 3.12.4
expected stdout:
tox from 3.11.9
Scenario: an alias is a version to list and not a version to skip #
only when pyenv --version succeeds · skipped on Windows
Given #
- Fixture file
root/versions/3.11.9/bin/pythonis created. - Fixture file
root/versions/stableis created. - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected). - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture root/versions/3.11.9/bin/python:
#!/bin/sh
echo "Python 3.11.9"
When #
pyenv versions --bare
pyenv versions --bare --skip-aliases
pyenv local stable
pyenv which python
Then #
- after
pyenv versions --bare:- exit code is
0 - stdout equals an exact value
- exit code is
- after
pyenv versions --bare --skip-aliases:- exit code is
0 - stdout equals an exact value
- exit code is
- after
pyenv local stable:- exit code is
0
- exit code is
- after
pyenv which python:- exit code is
0 - stdout matches
//root/versions/stable/bin/python\n$/
- exit code is
Expected output #
expected stdout:
3.11.9
stable
expected stdout:
3.11.9
Scenario: a version file naming something that is not installed says which file #
only when pyenv --version succeeds · skipped on Windows
Given #
- Fixture file
root/versions/3.11.9/bin/pythonis created. - Fixture file
.python-versionis created. - Environment variables are set: PYENV_ROOT.
- The command runs with an isolated home under
${workdir}/.atago-home(HOME/XDG or APPDATA redirected).
Inputs #
Fixture root/versions/3.11.9/bin/python:
#!/bin/sh
echo "Python 3.11.9"
Fixture .python-version:
3.11.9
9.9.9
When #
pyenv version
Then #
- exit code is
1 - stderr matches
/pyenv: version `9\.9\.9' is not installed \(set by .*/\.python-version\)/