2016-07-20 14:50:22 -04:00
|
|
|
"""Vox tests"""
|
2022-01-31 21:26:34 +05:30
|
|
|
import os
|
2021-08-11 12:16:32 +05:30
|
|
|
import pathlib
|
2016-07-20 14:50:22 -04:00
|
|
|
import stat
|
2019-08-04 12:20:04 +10:00
|
|
|
import subprocess as sp
|
2022-01-31 21:26:34 +05:30
|
|
|
import sys
|
2021-10-13 19:32:06 +05:30
|
|
|
import types
|
2022-01-31 21:26:34 +05:30
|
|
|
from typing import TYPE_CHECKING
|
2021-10-13 19:32:06 +05:30
|
|
|
|
2016-10-02 21:49:38 -04:00
|
|
|
import pytest
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2020-08-05 07:29:31 -07:00
|
|
|
from tools import skip_if_on_conda, skip_if_on_msys
|
2016-10-02 21:49:38 -04:00
|
|
|
from xonsh.platform import ON_WINDOWS
|
2022-01-31 21:26:34 +05:30
|
|
|
from xontrib.voxapi import Vox
|
2021-12-22 11:17:53 +05:30
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from xontrib.vox import VoxHandler
|
2016-07-23 11:21:41 -04:00
|
|
|
|
2016-07-23 17:27:27 -04:00
|
|
|
|
2021-08-11 12:16:32 +05:30
|
|
|
@pytest.fixture
|
2021-12-22 11:17:53 +05:30
|
|
|
def vox(xession, tmpdir, load_xontrib) -> "VoxHandler":
|
|
|
|
"""vox Alias function"""
|
2021-08-11 12:16:32 +05:30
|
|
|
|
|
|
|
# Set up an isolated venv home
|
|
|
|
xession.env["VIRTUALENV_HOME"] = str(tmpdir)
|
|
|
|
|
|
|
|
# Set up enough environment for xonsh to function
|
|
|
|
xession.env["PWD"] = os.getcwd()
|
|
|
|
xession.env["DIRSTACK_SIZE"] = 10
|
|
|
|
xession.env["PATH"] = []
|
|
|
|
xession.env["XONSH_SHOW_TRACEBACK"] = True
|
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
load_xontrib("vox")
|
2016-08-28 13:37:23 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
yield xession.aliases["vox"]
|
2016-08-28 13:37:23 -04:00
|
|
|
|
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
@pytest.fixture
|
|
|
|
def record_events(xession):
|
|
|
|
class Listener:
|
|
|
|
def __init__(self):
|
|
|
|
self.last = None
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
def listener(self, name):
|
|
|
|
def _wrapper(**kwargs):
|
|
|
|
self.last = (name,) + tuple(kwargs.values())
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
return _wrapper
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
def __call__(self, *events: str):
|
|
|
|
for name in events:
|
|
|
|
event = getattr(xession.builtins.events, name)
|
|
|
|
event(self.listener(name))
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
yield Listener()
|
2016-07-20 14:50:22 -04:00
|
|
|
|
2016-07-23 17:27:27 -04:00
|
|
|
|
2017-12-31 17:36:21 +01:00
|
|
|
@skip_if_on_msys
|
2016-07-23 17:27:27 -04:00
|
|
|
@skip_if_on_conda
|
2021-12-22 11:17:53 +05:30
|
|
|
def test_vox_flow(xession, vox, record_events, tmpdir):
|
2016-07-20 14:50:22 -04:00
|
|
|
"""
|
|
|
|
Creates a virtual environment, gets it, enumerates it, and then deletes it.
|
|
|
|
"""
|
2021-05-20 15:44:26 +05:30
|
|
|
xession.env["VIRTUALENV_HOME"] = str(tmpdir)
|
2016-08-28 13:37:23 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
record_events(
|
|
|
|
"vox_on_create", "vox_on_delete", "vox_on_activate", "vox_on_deactivate"
|
|
|
|
)
|
2016-08-28 13:37:23 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
vox(["create", "spam"])
|
|
|
|
assert stat.S_ISDIR(tmpdir.join("spam").stat().mode)
|
|
|
|
assert record_events.last == ("vox_on_create", "spam")
|
2016-08-28 13:37:23 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
ve = vox.vox["spam"]
|
|
|
|
assert ve.env == str(tmpdir.join("spam"))
|
|
|
|
assert os.path.isdir(ve.bin)
|
2016-08-28 13:37:23 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
assert "spam" in vox.vox
|
|
|
|
assert "spam" in list(vox.vox)
|
|
|
|
|
|
|
|
# activate/deactivate
|
|
|
|
vox(["activate", "spam"])
|
|
|
|
assert xession.env["VIRTUAL_ENV"] == vox.vox["spam"].env
|
|
|
|
assert record_events.last == ("vox_on_activate", "spam", str(ve.env))
|
2016-07-20 14:50:22 -04:00
|
|
|
vox.deactivate()
|
2021-05-20 15:44:26 +05:30
|
|
|
assert "VIRTUAL_ENV" not in xession.env
|
2021-12-22 11:17:53 +05:30
|
|
|
assert record_events.last == ("vox_on_deactivate", "spam", str(ve.env))
|
|
|
|
|
|
|
|
# removal
|
|
|
|
vox(["rm", "spam", "--force"])
|
|
|
|
assert not tmpdir.join("spam").check()
|
|
|
|
assert record_events.last == ("vox_on_delete", "spam")
|
2016-07-30 03:35:39 -04:00
|
|
|
|
|
|
|
|
2019-08-04 12:20:04 +10:00
|
|
|
@skip_if_on_msys
|
|
|
|
@skip_if_on_conda
|
2021-12-22 11:17:53 +05:30
|
|
|
def test_activate_non_vox_venv(xession, vox, record_events, tmpdir):
|
2019-08-04 12:20:04 +10:00
|
|
|
"""
|
|
|
|
Create a virtual environment using Python's built-in venv module
|
|
|
|
(not in VIRTUALENV_HOME) and verify that vox can activate it correctly.
|
|
|
|
"""
|
2022-01-08 04:03:22 +05:30
|
|
|
xession.env["PATH"] = []
|
2019-08-04 12:20:04 +10:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
record_events("vox_on_activate", "vox_on_deactivate")
|
2019-08-04 12:20:04 +10:00
|
|
|
|
|
|
|
with tmpdir.as_cwd():
|
2020-08-26 10:10:59 -05:00
|
|
|
venv_dirname = "venv"
|
|
|
|
sp.run([sys.executable, "-m", "venv", venv_dirname])
|
2021-12-22 11:17:53 +05:30
|
|
|
vox(["activate", venv_dirname])
|
|
|
|
vxv = vox.vox[venv_dirname]
|
2019-08-04 12:20:04 +10:00
|
|
|
|
2021-05-20 15:44:26 +05:30
|
|
|
env = xession.env
|
2019-08-04 12:20:04 +10:00
|
|
|
assert os.path.isabs(vxv.bin)
|
|
|
|
assert env["PATH"][0] == vxv.bin
|
|
|
|
assert os.path.isabs(vxv.env)
|
|
|
|
assert env["VIRTUAL_ENV"] == vxv.env
|
2021-12-22 11:17:53 +05:30
|
|
|
assert record_events.last == (
|
|
|
|
"vox_on_activate",
|
2019-08-16 20:33:51 +10:00
|
|
|
venv_dirname,
|
2021-12-22 11:17:53 +05:30
|
|
|
str(pathlib.Path(str(tmpdir)) / venv_dirname),
|
2019-08-16 20:33:51 +10:00
|
|
|
)
|
2019-08-04 12:20:04 +10:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
vox(["deactivate"])
|
2019-08-04 12:20:04 +10:00
|
|
|
assert not env["PATH"]
|
|
|
|
assert "VIRTUAL_ENV" not in env
|
2021-12-22 11:17:53 +05:30
|
|
|
assert record_events.last == (
|
|
|
|
"vox_on_deactivate",
|
|
|
|
venv_dirname,
|
|
|
|
str(pathlib.Path(str(tmpdir)) / venv_dirname),
|
2019-08-16 20:33:51 +10:00
|
|
|
)
|
2019-08-04 12:20:04 +10:00
|
|
|
|
|
|
|
|
2017-12-31 17:36:21 +01:00
|
|
|
@skip_if_on_msys
|
2016-07-30 03:35:39 -04:00
|
|
|
@skip_if_on_conda
|
2021-12-22 11:17:53 +05:30
|
|
|
def test_path(xession, vox, tmpdir, a_venv):
|
2016-07-30 03:35:39 -04:00
|
|
|
"""
|
|
|
|
Test to make sure Vox properly activates and deactivates by examining $PATH
|
|
|
|
"""
|
2021-05-20 15:44:26 +05:30
|
|
|
oldpath = list(xession.env["PATH"])
|
2021-12-22 11:17:53 +05:30
|
|
|
vox(["activate", a_venv.basename])
|
2018-08-30 09:18:49 -05:00
|
|
|
|
2021-05-20 15:44:26 +05:30
|
|
|
assert oldpath != xession.env["PATH"]
|
2016-07-30 03:35:39 -04:00
|
|
|
|
|
|
|
vox.deactivate()
|
2018-08-30 09:18:49 -05:00
|
|
|
|
2021-05-20 15:44:26 +05:30
|
|
|
assert oldpath == xession.env["PATH"]
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2016-10-02 21:49:38 -04:00
|
|
|
|
2017-12-31 17:36:21 +01:00
|
|
|
@skip_if_on_msys
|
2016-09-13 20:49:34 -04:00
|
|
|
@skip_if_on_conda
|
2021-05-20 15:44:26 +05:30
|
|
|
def test_crud_subdir(xession, tmpdir):
|
2016-09-13 20:49:34 -04:00
|
|
|
"""
|
|
|
|
Creates a virtual environment, gets it, enumerates it, and then deletes it.
|
|
|
|
"""
|
2021-05-20 15:44:26 +05:30
|
|
|
xession.env["VIRTUALENV_HOME"] = str(tmpdir)
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2021-11-26 23:37:35 +05:30
|
|
|
vox = Vox(force_removals=True)
|
2018-08-30 09:18:49 -05:00
|
|
|
vox.create("spam/eggs")
|
|
|
|
assert stat.S_ISDIR(tmpdir.join("spam", "eggs").stat().mode)
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2018-08-30 09:18:49 -05:00
|
|
|
ve = vox["spam/eggs"]
|
|
|
|
assert ve.env == str(tmpdir.join("spam", "eggs"))
|
2016-09-13 20:49:34 -04:00
|
|
|
assert os.path.isdir(ve.bin)
|
|
|
|
|
2018-08-30 09:18:49 -05:00
|
|
|
assert "spam/eggs" in vox
|
|
|
|
assert "spam" not in vox
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2018-08-30 09:18:49 -05:00
|
|
|
# assert 'spam/eggs' in list(vox) # This is NOT true on Windows
|
|
|
|
assert "spam" not in list(vox)
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2018-08-30 09:18:49 -05:00
|
|
|
del vox["spam/eggs"]
|
|
|
|
|
|
|
|
assert not tmpdir.join("spam", "eggs").check()
|
2016-09-13 20:49:34 -04:00
|
|
|
|
2016-10-02 21:49:38 -04:00
|
|
|
|
2021-08-11 12:16:32 +05:30
|
|
|
@skip_if_on_msys
|
|
|
|
@skip_if_on_conda
|
|
|
|
def test_crud_path(xession, tmpdir):
|
|
|
|
"""
|
|
|
|
Creates a virtual environment, gets it, enumerates it, and then deletes it.
|
|
|
|
"""
|
|
|
|
tmp = pathlib.Path(str(tmpdir))
|
2016-12-09 23:14:41 -05:00
|
|
|
|
2021-11-26 23:37:35 +05:30
|
|
|
vox = Vox(force_removals=True)
|
2021-08-11 12:16:32 +05:30
|
|
|
vox.create(tmp)
|
|
|
|
assert stat.S_ISDIR(tmpdir.join("lib").stat().mode)
|
2016-12-09 23:14:41 -05:00
|
|
|
|
2021-08-11 12:16:32 +05:30
|
|
|
ve = vox[tmp]
|
|
|
|
assert ve.env == str(tmp)
|
|
|
|
assert os.path.isdir(ve.bin)
|
2016-12-09 23:14:41 -05:00
|
|
|
|
2021-08-11 12:16:32 +05:30
|
|
|
del vox[tmp]
|
2016-12-09 23:14:41 -05:00
|
|
|
|
2021-08-11 12:16:32 +05:30
|
|
|
assert not tmpdir.check()
|
2016-12-09 23:14:41 -05:00
|
|
|
|
2016-10-02 21:49:38 -04:00
|
|
|
|
2017-12-31 17:36:21 +01:00
|
|
|
@skip_if_on_msys
|
2016-10-02 21:49:38 -04:00
|
|
|
@skip_if_on_conda
|
2021-05-20 15:44:26 +05:30
|
|
|
def test_reserved_names(xession, tmpdir):
|
2016-10-02 21:49:38 -04:00
|
|
|
"""
|
2019-08-28 14:07:27 -04:00
|
|
|
Tests that reserved words are disallowed.
|
2016-10-02 21:49:38 -04:00
|
|
|
"""
|
2021-05-20 15:44:26 +05:30
|
|
|
xession.env["VIRTUALENV_HOME"] = str(tmpdir)
|
2016-10-02 21:49:38 -04:00
|
|
|
|
|
|
|
vox = Vox()
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
if ON_WINDOWS:
|
2018-08-30 09:18:49 -05:00
|
|
|
vox.create("Scripts")
|
2016-10-02 21:49:38 -04:00
|
|
|
else:
|
2018-08-30 09:18:49 -05:00
|
|
|
vox.create("bin")
|
2016-10-02 21:49:38 -04:00
|
|
|
|
|
|
|
with pytest.raises(ValueError):
|
|
|
|
if ON_WINDOWS:
|
2018-08-30 09:18:49 -05:00
|
|
|
vox.create("spameggs/Scripts")
|
2016-10-02 21:49:38 -04:00
|
|
|
else:
|
2018-08-30 09:18:49 -05:00
|
|
|
vox.create("spameggs/bin")
|
2019-08-28 14:50:27 -04:00
|
|
|
|
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
@pytest.mark.parametrize("registered", [False, True])
|
2019-08-28 14:50:27 -04:00
|
|
|
@skip_if_on_msys
|
|
|
|
@skip_if_on_conda
|
2021-12-22 11:17:53 +05:30
|
|
|
def test_autovox(xession, tmpdir, vox, a_venv, load_xontrib, registered):
|
2019-08-28 14:50:27 -04:00
|
|
|
"""
|
|
|
|
Tests that autovox works
|
|
|
|
"""
|
2022-01-31 21:26:34 +05:30
|
|
|
from xonsh.dirstack import popd, pushd
|
2019-08-28 14:50:27 -04:00
|
|
|
|
|
|
|
# Makes sure that event handlers are registered
|
2021-12-22 11:17:53 +05:30
|
|
|
load_xontrib("autovox")
|
2020-08-26 10:10:59 -05:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
env_name = a_venv.basename
|
|
|
|
env_path = str(a_venv)
|
2019-08-28 14:50:27 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
# init properly
|
|
|
|
assert vox.parser
|
2019-08-28 14:50:27 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
def policy(path, **_):
|
|
|
|
if str(path) == env_path:
|
|
|
|
return env_name
|
2019-08-28 14:50:27 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
if registered:
|
|
|
|
xession.builtins.events.autovox_policy(policy)
|
2019-08-28 14:50:27 -04:00
|
|
|
|
2021-12-22 11:17:53 +05:30
|
|
|
pushd([env_path])
|
|
|
|
value = env_name if registered else None
|
|
|
|
assert vox.vox.active() == value
|
|
|
|
popd([])
|
2021-10-13 19:32:06 +05:30
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def venv_home(tmpdir):
|
|
|
|
"""Path where VENVs are created"""
|
|
|
|
return tmpdir
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def venvs(venv_home):
|
2021-12-22 11:17:53 +05:30
|
|
|
"""Create virtualenv with names venv0, venv1"""
|
2022-01-31 21:26:34 +05:30
|
|
|
from xonsh.dirstack import popd, pushd
|
2021-10-13 19:32:06 +05:30
|
|
|
|
|
|
|
pushd([str(venv_home)])
|
|
|
|
paths = []
|
|
|
|
for idx in range(2):
|
2021-12-22 11:17:53 +05:30
|
|
|
env_path = venv_home / f"venv{idx}"
|
|
|
|
bin_path = env_path / "bin"
|
|
|
|
paths.append(env_path)
|
2021-10-13 19:32:06 +05:30
|
|
|
|
|
|
|
(bin_path / "python").write("", ensure=True)
|
|
|
|
(bin_path / "python.exe").write("", ensure=True)
|
|
|
|
for file in bin_path.listdir():
|
|
|
|
st = os.stat(str(file))
|
|
|
|
os.chmod(str(file), st.st_mode | stat.S_IEXEC)
|
|
|
|
yield paths
|
|
|
|
popd([])
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
2021-12-22 11:17:53 +05:30
|
|
|
def a_venv(venvs):
|
|
|
|
return venvs[0]
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def patched_cmd_cache(xession, vox, venvs, monkeypatch):
|
2021-10-13 19:32:06 +05:30
|
|
|
cc = xession.commands_cache
|
|
|
|
|
|
|
|
def no_change(self, *_):
|
|
|
|
return False, False, False
|
|
|
|
|
2022-01-08 04:03:22 +05:30
|
|
|
monkeypatch.setattr(cc, "_check_changes", types.MethodType(no_change, cc))
|
2021-10-13 19:32:06 +05:30
|
|
|
monkeypatch.setattr(cc, "_update_cmds_cache", types.MethodType(no_change, cc))
|
|
|
|
bins = {path: (path, False) for path in _PY_BINS}
|
|
|
|
cc._cmds_cache.update(bins)
|
|
|
|
yield cc
|
|
|
|
|
|
|
|
|
|
|
|
_VENV_NAMES = {"venv1", "venv1/", "venv0/", "venv0"}
|
|
|
|
if ON_WINDOWS:
|
|
|
|
_VENV_NAMES = {"venv1\\", "venv0\\"}
|
|
|
|
|
|
|
|
_HELP_OPTS = {
|
|
|
|
"-h",
|
|
|
|
"--help",
|
|
|
|
}
|
|
|
|
_PY_BINS = {"/bin/python2", "/bin/python3"}
|
2021-12-22 11:17:53 +05:30
|
|
|
|
2021-10-13 19:32:06 +05:30
|
|
|
_VOX_NEW_OPTS = {
|
|
|
|
"--ssp",
|
|
|
|
"--system-site-packages",
|
|
|
|
"--without-pip",
|
2021-11-26 23:37:35 +05:30
|
|
|
}.union(_HELP_OPTS)
|
2021-10-13 19:32:06 +05:30
|
|
|
_VOX_NEW_EXP = _PY_BINS.union(_VOX_NEW_OPTS)
|
2021-12-22 11:17:53 +05:30
|
|
|
|
|
|
|
if ON_WINDOWS:
|
|
|
|
_VOX_NEW_OPTS.add("--symlinks")
|
|
|
|
else:
|
|
|
|
_VOX_NEW_OPTS.add("--copies")
|
|
|
|
|
2021-11-26 23:37:35 +05:30
|
|
|
_VOX_RM_OPTS = {"-f", "--force"}.union(_HELP_OPTS)
|
2021-10-13 19:32:06 +05:30
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"args, positionals, opts",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"vox",
|
|
|
|
{
|
|
|
|
"delete",
|
|
|
|
"new",
|
|
|
|
"remove",
|
|
|
|
"del",
|
|
|
|
"workon",
|
|
|
|
"list",
|
|
|
|
"exit",
|
2021-11-26 23:37:35 +05:30
|
|
|
"info",
|
2021-10-13 19:32:06 +05:30
|
|
|
"ls",
|
|
|
|
"rm",
|
|
|
|
"deactivate",
|
|
|
|
"activate",
|
|
|
|
"enter",
|
|
|
|
"create",
|
2021-11-26 23:37:35 +05:30
|
|
|
"project-get",
|
|
|
|
"project-set",
|
|
|
|
"runin",
|
|
|
|
"runin-all",
|
|
|
|
"toggle-ssp",
|
|
|
|
"wipe",
|
2021-12-22 11:17:53 +05:30
|
|
|
"upgrade",
|
2021-10-13 19:32:06 +05:30
|
|
|
},
|
|
|
|
_HELP_OPTS,
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"vox create",
|
|
|
|
set(),
|
2021-11-26 23:37:35 +05:30
|
|
|
_VOX_NEW_OPTS.union(
|
|
|
|
{
|
|
|
|
"-a",
|
|
|
|
"--activate",
|
|
|
|
"--wp",
|
|
|
|
"--without-pip",
|
|
|
|
"-p",
|
|
|
|
"--interpreter",
|
|
|
|
"-i",
|
|
|
|
"--install",
|
|
|
|
"-l",
|
|
|
|
"--link",
|
|
|
|
"--link-project",
|
|
|
|
"-r",
|
|
|
|
"--requirements",
|
|
|
|
"-t",
|
|
|
|
"--temp",
|
2022-02-21 10:21:31 +01:00
|
|
|
"--prompt",
|
2021-11-26 23:37:35 +05:30
|
|
|
}
|
|
|
|
),
|
2021-10-13 19:32:06 +05:30
|
|
|
),
|
2021-11-26 23:37:35 +05:30
|
|
|
("vox activate", _VENV_NAMES, _HELP_OPTS.union({"-n", "--no-cd"})),
|
|
|
|
("vox rm", _VENV_NAMES, _VOX_RM_OPTS),
|
|
|
|
("vox rm venv1", _VENV_NAMES, _VOX_RM_OPTS), # pos nargs: one or more
|
|
|
|
("vox rm venv1 venv2", _VENV_NAMES, _VOX_RM_OPTS), # pos nargs: two or more
|
2021-10-13 19:32:06 +05:30
|
|
|
("vox new --activate --interpreter", _PY_BINS, set()), # option after option
|
|
|
|
("vox new --interpreter", _PY_BINS, set()), # "option: first
|
|
|
|
("vox new --activate env1 --interpreter", _PY_BINS, set()), # option after pos
|
|
|
|
("vox new env1 --interpreter", _PY_BINS, set()), # "option: at end"
|
|
|
|
("vox new env1 --interpreter=", _PY_BINS, set()), # "option: at end with
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_vox_completer(
|
|
|
|
args, check_completer, positionals, opts, xession, patched_cmd_cache, venv_home
|
|
|
|
):
|
|
|
|
xession.env["XONSH_DATA_DIR"] = venv_home
|
|
|
|
if positionals:
|
|
|
|
assert check_completer(args) == positionals
|
|
|
|
xession.env["ALIAS_COMPLETIONS_OPTIONS_BY_DEFAULT"] = True
|
|
|
|
if opts:
|
|
|
|
assert check_completer(args) == positionals.union(opts)
|