Repository: pyenv-win/pyenv-win (language: python)

Issue:
Rehash: All installed versions, tests & more shims
- rehash all installed versions
- add unit tests
- install more shims for pythonX, pythonXY, pythonwX & pythonwXY

![image](https://user-images.githubusercontent.com/626824/111915726-020c4800-8a78-11eb-9644-53e25814ec2d.png)

![image](https://user-images.githubusercontent.com/626824/111914794-d6875e80-8a73-11eb-83f1-c9c97569cbd6.png)

bug: setting multiple versions with 1+ arguments does not work
**Describe the bug**
In the Linux version of pyenv, you can set multiple local (or global, or shell, etc.) versions and they will be respected. This is very important for integrating with tox:

pyenv local 2.7.15 3.7.0
pyenv versions
  system
\* 2.7.15 (set by.../.python-version)
\* 3.7.0 (set by .../.python-version)

In Windows, the same command only sets the local version to the first argument and ignores the subsequent:
pyenv local 2.7.15 3.7.0
pyenv versions
  system
\* 2.7.15 (set by.../.python-version)
  3.7.0 (set by .../.python-version)

**To Reproduce**
Using pyenv windows, type the following:
pyenv local 2.7.15 3.7.0

Note that only the first argument has been respected. 

Editing the .python-version file directly does not work either. 

**Expected behavior**
local python version should be set to both 

**Screenshots**

**Desktop (please complete the following information):**
 - OS: Windows 10
 - Tools used Powershell
 - Version [e.g. 22]

**Additional context**
N/A



Discussion / hints:

#3 We know this limitation, we need some guidance how to achieve this for windows.

Fix patch:
diff --git a/pyenv-win/libexec/libs/pyenv-lib.vbs b/pyenv-win/libexec/libs/pyenv-lib.vbs
index 096af74b..241cd706 100644
--- a/pyenv-win/libexec/libs/pyenv-lib.vbs
+++ b/pyenv-win/libexec/libs/pyenv-lib.vbs
@@ -65,30 +65,49 @@ Function GetCurrentVersionGlobal()
     End If
 End Function
 
-Function GetCurrentVersionLocal(path)
-    ' WScript.echo "kkotari: pyenv-lib.vbs get current version local..!"
-    GetCurrentVersionLocal = Null
-
+Function GetCurrentVersionsLocal(path)
+    ' WScript.echo "kkotari: pyenv-lib.vbs get current versions local..!"
     Dim fname
     Dim objFile
+    Dim line
+    ReDim versions(-1)
     Do While path <> ""
         fname = path & strVerFile
         If objfs.FileExists(fname) Then
             Set objFile = objfs.OpenTextFile(fname)
-            If objFile.AtEndOfStream <> True Then
-               GetCurrentVersionLocal = Array(objFile.ReadLine, fname)
-            End If
+            Do While objFile.AtEndOfStream <> True
+                line = objFile.ReadLine
+                If line <> "" Then
+                    ReDim Preserve versions (UBound(versions) + 1)
+                    versions(UBound(versions)) = Array(line, fname)
+                End If
+            Loop
             objFile.Close
-            Exit Function
+            Exit Do
         End If
         path = objfs.GetParentFolderName(path)
     Loop
+    if UBound(versions) >= 0 Then
+        GetCurrentVersionsLocal = versions
+    Else
+        GetCurrentVersionsLocal = Null
+    End If
+End Function
+
+Function GetFirstVersionLocal(path)
+    ' WScript.echo "kkotari: pyenv-lib.vbs get first version local..!"
+    Dim versions
+    versions = GetCurrentVersionsLocal(path)
+    if IsNull(versions) Then
+        GetFirstVersionLocal = Null
+    Else
+        GetFirstVersionLocal = versions(0)
+    End If
 End Function
 
 Function GetCurrentVersionShell()
     ' WScript.echo "kkotari: pyenv-lib.vbs get current version shell..!"
     GetCurrentVersionShell = Null
-
     Dim str
     str = objws.Environment("Process")("PYENV_VERSION")
     If str <> "" Then _
@@ -98,9 +117,7 @@ End Function
 Function GetCurrentVersion()
     ' WScript.echo "kkotari: pyenv-lib.vbs get current version..!"
     Dim str
-    str = GetCurrentVersionShell
-    If IsNull(str) Then str = GetCurrentVersionLocal(strCurrent)
-    If IsNull(str) Then str = GetCurrentVersionGlobal
+    str = GetCurrentVersionNoError
     If IsNull(str) Then
 		WScript.echo "No global python version has been set yet. Please set the global version by typing:"
 		WScript.echo "pyenv global 3.7.2"
@@ -113,11 +130,47 @@ Function GetCurrentVersionNoError()
     ' WScript.echo "kkotari: pyenv-lib.vbs get current version no error..!"
     Dim str
     str = GetCurrentVersionShell
-    If IsNull(str) Then str = GetCurrentVersionLocal(strCurrent)
+    If IsNull(str) Then str = GetFirstVersionLocal(strCurrent)
     If IsNull(str) Then str = GetCurrentVersionGlobal
     GetCurrentVersionNoError = str
 End Function
 
+Function GetCurrentVersions()
+    ' WScript.echo "kkotari: pyenv-lib.vbs get current versions..!"
+    Dim versions
+    Set versions = GetCurrentVersionsNoError
+    If versions.Count = 0 Then
+		WScript.echo "No global python version has been set yet. Please set the global version by typing:"
+		WScript.echo "pyenv global 3.7.2"
+		WScript.quit
+	End If
+	Set GetCurrentVersions = versions
+End Function
+
+Function GetCurrentVersionsNoError()
+    ' WScript.echo "kkotari: pyenv-lib.vbs get current version no error..!"
+    Dim versions
+    Set versions = CreateObject("Scripting.Dictionary")
+    Dim str
+    str = GetCurrentVersionShell
+    If Not(IsNull(str)) Then
+        versions.Add str(0), str(1)
+    Else
+        str = GetCurrentVersionsLocal(strCurrent)
+        If Not(IsNull(str)) Then
+            Dim v1
+            For Each v1 in str
+                versions.Add v1(0), v1(1)
+            Next
+        End If
+    End If
+    If IsNull(str) Then
+        str = GetCurrentVersionGlobal
+        If Not(IsNull(str)) Then versions.Add str(0), str(1)
+    End If
+    Set GetCurrentVersionsNoError = versions
+End Function
+
 Function GetInstalledVersions()
     ' WScript.echo "kkotari: pyenv-lib.vbs get installed versions..!"
     Dim rootBinDir, winBinDir, version, versions()
diff --git a/pyenv-win/libexec/pyenv-install.vbs b/pyenv-win/libexec/pyenv-install.vbs
index 304b46dd..4973e714 100644
--- a/pyenv-win/libexec/pyenv-install.vbs
+++ b/pyenv-win/libexec/pyenv-install.vbs
@@ -312,6 +312,7 @@ Sub main(arg)
     Else
         If installVersions.Count = 0 Then
             Dim ary
+            ' TODO Should we handle many versions here?
             ary = GetCurrentVersionNoError()
             If Not IsNull(ary) Then
                 installVersions.Item(ary(0)) = Empty
diff --git a/pyenv-win/libexec/pyenv-local.bat b/pyenv-win/libexec/pyenv-local.bat
index 67d92233..1fcbe7ef 100644
--- a/pyenv-win/libexec/pyenv-local.bat
+++ b/pyenv-win/libexec/pyenv-local.bat
@@ -2,7 +2,7 @@
 setlocal
 
 if "%1" == "--help" (
-echo Usage: pyenv local ^<version^>
+echo Usage: pyenv local ^<version^> ^<version2^> ^<..^>
 echo        pyenv local --unset
 echo.
 echo Sets the local application-specific Python version by writing the
@@ -15,6 +15,15 @@ echo specified with `pyenv global'. A version specified with the
 echo `PYENV_VERSION' environment variable takes precedence over local
 echo and global versions.
 echo.
+echo ^<version^> can be specified multiple times and should be a version
+echo tag known to pyenv.  The special version string `system' will use
+echo your default system Python.  Run `pyenv versions' for a list of
+echo available Python versions.
+echo.
+echo Example: To enable the python2.7 and python3.7 shims to find their
+echo          respective executables you could set both versions with:
+echo.
+echo 'pyenv local 3.7.0 2.7.15'
 EXIT /B
 )
 
diff --git a/pyenv-win/libexec/pyenv.vbs b/pyenv-win/libexec/pyenv.vbs
index f9fff762..2b3918d1 100644
--- a/pyenv-win/libexec/pyenv.vbs
+++ b/pyenv-win/libexec/pyenv.vbs
@@ -137,44 +137,47 @@ Sub CommandWhich(arg)
     Dim version
 
     program = arg(1)
-    version = objws.Environment("Process")("PYENV_VERSION")
-
     If program = "" Then PrintHelp "pyenv-which", 1
-    If version = "" Then version = GetCurrentVersion()(0)
     If Right(program, 1) = "." Then program = Left(program, Len(program)-1)
 
     Set exts = GetExtensions(True)
 
-    If Not objfs.FolderExists(strDirVers &"\"& version) Then
-        WScript.Echo "pyenv: version `"& version &"' is not installed (set by "& version &")"
-        WScript.Quit 1
-    End If
-
-    If objfs.FileExists(strDirVers &"\"& version &"\"& program) Then
-        WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\"& program).Path
-        WScript.Quit 0
-    End If
+    Dim versions
+    Set versions = GetCurrentVersions
+    For Each version In versions
 
-    For Each ext In exts.Keys
-        If objfs.FileExists(strDirVers &"\"& version &"\"& program & ext) Then
-            WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\"& program & ext).Path
-            WScript.Quit 0
+        If Not objfs.FolderExists(strDirVers &"\"& version) Then
+            WScript.Echo "pyenv: version `"& version &"' is not installed (set by "& version &")"
+            WScript.Quit 1
         End If
-    Next
 
-    If objfs.FolderExists(strDirVers &"\"& version & "\Scripts") Then
-        If objfs.FileExists(strDirVers &"\"& version &"\Scripts\"& program) Then
-            WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\Scripts\"& program).Path
+        If objfs.FileExists(strDirVers &"\"& version &"\"& program) Then
+            WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\"& program).Path
             WScript.Quit 0
         End If
 
         For Each ext In exts.Keys
-            If objfs.FileExists(strDirVers &"\"& version &"\Scripts\"& program & ext) Then
-                WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\Scripts\"& program & ext).Path
+            If objfs.FileExists(strDirVers &"\"& version &"\"& program & ext) Then
+                WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\"& program & ext).Path
                 WScript.Quit 0
             End If
         Next
-    End If
+
+        If objfs.FolderExists(strDirVers &"\"& version & "\Scripts") Then
+            If objfs.FileExists(strDirVers &"\"& version &"\Scripts\"& program) Then
+                WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\Scripts\"& program).Path
+                WScript.Quit 0
+            End If
+
+            For Each ext In exts.Keys
+                If objfs.FileExists(strDirVers &"\"& version &"\Scripts\"& program & ext) Then
+                    WScript.Echo objfs.GetFile(strDirVers &"\"& version &"\Scripts\"& program & ext).Path
+                    WScript.Quit 0
+                End If
+            Next
+        End If
+    Next
+
     WScript.Echo "pyenv: "& arg(1) &": command not found"
 
     version = getCommandOutput("cscript //Nologo "& WScript.ScriptFullName &" whence "& program)
@@ -402,11 +405,14 @@ Sub CommandLocal(arg)
 
     Dim ver
     If arg.Count < 2 Then
-        ver = GetCurrentVersionLocal(strCurrent)
-        If IsNull(ver) Then
+        Dim currentVersions
+        currentVersions = GetCurrentVersionsLocal(strCurrent)
+        If IsNull(currentVersions) Then
             WScript.Echo "no local version configured for this directory"
         Else
-            WScript.Echo ver(0)
+            For Each ver in currentVersions
+                WScript.Echo ver(0)
+            Next
         End If
     Else
         If arg(1) = "--unset" Then
@@ -414,8 +420,14 @@ Sub CommandLocal(arg)
             objfs.DeleteFile strCurrent & strVerFile, True
             Exit Sub
         Else
-            ver = Check32Bit(arg(1))
-            GetBinDir(ver)
+            Dim versionCount
+            versionCount = arg.Count - 1
+            ReDim localVersions(versionCount - 1)
+            Dim i
+            For i = 0 To versionCount - 1
+                localVersions(i) = Check32Bit(arg(i + 1))
+                GetBinDir(localVersions(i))
+            Next
         End If
 
         Dim ofile
@@ -424,7 +436,9 @@ Sub CommandLocal(arg)
         Else
             Set ofile = objfs.CreateTextFile(strCurrent & strVerFile, True)
         End If
-        ofile.WriteLine(ver)
+        For Each ver in localVersions
+            ofile.WriteLine(ver)
+        Next
         ofile.Close()
     End If
 End Sub
@@ -463,8 +477,11 @@ Sub CommandVersion(arg)
     If Not objfs.FolderExists(strDirVers) Then objfs.CreateFolder(strDirVers)
 
     Dim curVer
-    curVer = GetCurrentVersion
-    WScript.Echo curVer(0) &" (set by "& curVer(1) &")"
+    Dim versions
+    Set versions = GetCurrentVersions
+    For Each curVer In versions
+        WScript.Echo curVer &" (set by "& versions(curVer) &")"
+    Next
 End Sub
 
 Sub CommandVersionName(arg)
@@ -475,18 +492,26 @@ Sub CommandVersionName(arg)
 
     If Not objfs.FolderExists(strDirVers) Then objfs.CreateFolder(strDirVers)
 
-    WScript.Echo GetCurrentVersion()(0)
+    Dim ver, versions
+    Set versions = GetCurrentVersions
+    For Each ver in versions
+        WScript.Echo ver
+    Next
 End Sub
 
 Sub CommandVersionNameShort(arg)
-    ' WScript.echo "kkotari: pyenv.vbs command v-name..!"
+    ' WScript.echo "kkotari: pyenv.vbs command vname..!"
     If arg.Count >= 2 Then
         If arg(1) = "--help" Then PrintHelp "pyenv-vname", 0
     End If
 
     If Not objfs.FolderExists(strDirVers) Then objfs.CreateFolder(strDirVers)
 
-    WScript.Echo GetCurrentVersion()(0)
+    Dim ver, versions
+    Set versions = GetCurrentVersions
+    For Each ver in versions
+        WScript.Echo ver
+    Next
 End Sub
 
 Sub CommandVersions(arg)
@@ -503,11 +528,8 @@ Sub CommandVersions(arg)
 
     If Not objfs.FolderExists(strDirVers) Then objfs.CreateFolder(strDirVers)
 
-    Dim curVer
-    curVer = GetCurrentVersionNoError
-    If IsNull(curVer) Then
-        curVer = Array("", "")
-    End If
+    Dim versions
+    Set versions = GetCurrentVersionsNoError
 
     Dim dir
     Dim ver
@@ -515,8 +537,8 @@ Sub CommandVersions(arg)
         ver = objfs.GetFileName(dir)
         If isBare Then
             WScript.Echo ver
-        ElseIf ver = curVer(0) Then
-            WScript.Echo "* "& ver &" (set by "& curVer(1) &")"
+        ElseIf versions.Exists(ver) Then
+            WScript.Echo "* "& ver &" (set by "& versions(ver) &")"
         Else
             WScript.Echo "  "& ver
         End If


Test patch:
diff --git a/tests/test_pyenv_feature_local.py b/tests/test_pyenv_feature_local.py
index eba0eaf1..9a67055e 100644
--- a/tests/test_pyenv_feature_local.py
+++ b/tests/test_pyenv_feature_local.py
@@ -1,5 +1,5 @@
 from test_pyenv import TestPyenvBase
-from test_pyenv_helpers import not_installed_output, run_pyenv_test
+from test_pyenv_helpers import local_python_versions, not_installed_output, run_pyenv_test
 
 
 class TestPyenvFeatureLocal(TestPyenvBase):
@@ -27,3 +27,19 @@ def test_local_set_unknown_version(self, setup):
         def commands(ctx):
             assert ctx.pyenv(["local", "3.7.8"]) == not_installed_output("3.7.8")
         run_pyenv_test({'versions': ["3.8.9"]}, commands)
+
+    def test_local_set_many_versions(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv(["local", "3.7.7", "3.8.9"]) == ""
+            assert local_python_versions(ctx.local_path) == "3.7.7\n3.8.9"
+        run_pyenv_test({'versions': ["3.7.7", "3.8.9"]}, commands)
+
+    def test_local_set_many_versions_one_not_installed(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv(["local", "3.7.7", "3.8.9"]) == not_installed_output("3.8.9")
+        run_pyenv_test({'versions': ["3.7.7"]}, commands)
+
+    def test_local_many_versions_defined(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv("local") == "3.7.7\r\n3.8.9"
+        run_pyenv_test({'local_ver': "3.7.7\n3.8.9\n"}, commands)
diff --git a/tests/test_pyenv_feature_version.py b/tests/test_pyenv_feature_version.py
index 5ec81db3..53fe092a 100644
--- a/tests/test_pyenv_feature_version.py
+++ b/tests/test_pyenv_feature_version.py
@@ -34,3 +34,13 @@ def commands(ctx):
         }
         with TemporaryEnvironment({"PYENV_VERSION": "3.9.2"}):
             run_pyenv_test(settings, commands)
+
+    def test_many_local_versions(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv("version") == (f'3.8.8 (set by {ctx.local_path}\\.python-version)\r\n'
+                                            f'3.9.1 (set by {ctx.local_path}\\.python-version)')
+        settings = {
+            'global_ver': "3.7.2",
+            'local_ver': "3.8.8\n3.9.1\n"
+        }
+        run_pyenv_test(settings, commands)
diff --git a/tests/test_pyenv_feature_version_name.py b/tests/test_pyenv_feature_version_name.py
new file mode 100644
index 00000000..328a91f6
--- /dev/null
+++ b/tests/test_pyenv_feature_version_name.py
@@ -0,0 +1,53 @@
+import pytest
+from tempenv import TemporaryEnvironment
+from test_pyenv_helpers import run_pyenv_test
+
+
+@pytest.mark.parametrize("command", ['version-name', 'vname'])
+def test_no_version(command):
+    def commands(ctx):
+        assert ctx.pyenv(command) == ("No global python version has been set yet. "
+                                      "Please set the global version by typing:\r\n"
+                                      "pyenv global 3.7.2")
+    run_pyenv_test({}, commands)
+
+
+@pytest.mark.parametrize("command", ['version-name', 'vname'])
+def test_global_version(command):
+    def commands(ctx):
+        assert ctx.pyenv(command) == "3.7.2"
+    run_pyenv_test({'global_ver': "3.7.2"}, commands)
+
+
+@pytest.mark.parametrize("command", ['version-name', 'vname'])
+def test_one_local_version(command):
+    def commands(ctx):
+        assert ctx.pyenv(command) == "3.9.1"
+    settings = {
+        'global_ver': "3.7.2",
+        'local_ver': "3.9.1"
+    }
+    run_pyenv_test(settings, commands)
+
+
+@pytest.mark.parametrize("command", ['version-name', 'vname'])
+def test_shell_version(command):
+    def commands(ctx):
+        assert ctx.pyenv(command) == "3.9.2"
+    settings = {
+        'global_ver': "3.7.5",
+        'local_ver': "3.8.6",
+    }
+    with TemporaryEnvironment({"PYENV_VERSION": "3.9.2"}):
+        run_pyenv_test(settings, commands)
+
+
+@pytest.mark.parametrize("command", ['version-name', 'vname'])
+def test_many_local_versions(command):
+    def commands(ctx):
+        assert ctx.pyenv(command) == "3.8.8\r\n3.9.1"
+    settings = {
+        'global_ver': "3.7.2",
+        'local_ver': "3.8.8\n3.9.1\n"
+    }
+    run_pyenv_test(settings, commands)
diff --git a/tests/test_pyenv_feature_versions.py b/tests/test_pyenv_feature_versions.py
index d7285700..1605ee0b 100644
--- a/tests/test_pyenv_feature_versions.py
+++ b/tests/test_pyenv_feature_versions.py
@@ -40,6 +40,18 @@ def commands(ctx):
         }
         run_pyenv_test(settings, commands)
 
+    def test_list_current_local_many_versions(self, setup):
+        def commands(ctx):
+            assert ctx.pyenv("versions") == (f"* 3.6.5 (set by {ctx.local_path}\\.python-version)\r\n"
+                                             f"* 3.7.7 (set by {ctx.local_path}\\.python-version)\r\n"
+                                             f"  3.9.1")
+        settings = {
+            'versions': ["3.6.5", "3.7.7", "3.9.1"],
+            'global_ver': "3.9.1",
+            'local_ver': "3.6.5\n3.7.7\n"
+        }
+        run_pyenv_test(settings, commands)
+
     def test_list_current_shell_version(self, setup):
         def commands(ctx):
             assert ctx.pyenv("versions") == (f"  3.6.5\r\n"
diff --git a/tests/test_pyenv_feature_which.py b/tests/test_pyenv_feature_which.py
index 4da8dbeb..0242da3c 100644
--- a/tests/test_pyenv_feature_which.py
+++ b/tests/test_pyenv_feature_which.py
@@ -3,13 +3,16 @@
 from test_pyenv_helpers import run_pyenv_test
 
 
+def assert_paths_equal(actual, expected):
+    assert actual.lower() == expected.lower()
+
+
 class TestPyenvFeatureWhich(TestPyenvBase):
     def test_which_exists_is_global(self, setup):
         def commands(ctx):
             for name in ['python', 'python3', 'python38', 'pip3', 'pip3.8']:
                 sub_dir = '' if 'python' in name else 'Scripts\\'
-                assert ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe' or \
-                    ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.EXE'
+                assert_paths_equal(ctx.pyenv(["which", name]), rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe')
         settings = {
             'versions': ['3.8.5'],
             'global_ver': '3.8.5'
@@ -20,8 +23,7 @@ def test_which_exists_is_local(self, setup):
         def commands(ctx):
             for name in ['python', 'python3', 'python38', 'pip3', 'pip3.8']:
                 sub_dir = '' if 'python' in name else 'Scripts\\'
-                assert ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe' or \
-                    ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.EXE'
+                assert_paths_equal(ctx.pyenv(["which", name]), rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe')
         settings = {
             'versions': ['3.8.5'],
             'local_ver': '3.8.5'
@@ -32,8 +34,7 @@ def test_which_exists_is_shell(self, setup):
         def commands(ctx):
             for name in ['python', 'python3', 'python38', 'pip3', 'pip3.8']:
                 sub_dir = '' if 'python' in name else 'Scripts\\'
-                assert ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe' or \
-                    ctx.pyenv(["which", name]) == rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.EXE'
+                assert_paths_equal(ctx.pyenv(["which", name]), rf'{ctx.pyenv_path}\versions\3.8.5\{sub_dir}{name}.exe')
         with TemporaryEnvironment({"PYENV_VERSION": "3.8.5"}):
             run_pyenv_test({'versions': ['3.8.5']}, commands)
 
@@ -118,3 +119,19 @@ def commands(ctx):
                                                       "Please set the global version by typing:\r\n"
                                                       "pyenv global 3.7.2")
         run_pyenv_test({'versions': ['3.8.6']}, commands)
+
+    def test_which_many_local_versions(self, setup):
+        def commands(ctx):
+            cases = [
+                ('python37', r'3.7.7\python37.exe'),
+                ('python38', r'3.8.2\python38.exe'),
+                ('pip3.7', r'3.7.7\Scripts\pip3.7.exe'),
+                ('pip3.8', r'3.8.2\Scripts\pip3.8.exe'),
+            ]
+            for (name, path) in cases:
+                assert_paths_equal(ctx.pyenv(["which", name]), rf'{ctx.pyenv_path}\versions\{path}')
+        settings = {
+            'versions': ['3.7.7', '3.8.2', '3.9.1'],
+            'local_ver': '3.7.7\n3.8.2\n'
+        }
+        run_pyenv_test(settings, commands)