2021-05-30 09:42:55 +03:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from xonsh.completers._aliases import add_one_completer
|
|
|
|
from xonsh.completers.tools import non_exclusive_completer
|
|
|
|
|
|
|
|
SIMPLE = lambda: None
|
|
|
|
NON_EXCLUSIVE = non_exclusive_completer(lambda: None)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"initial, exp",
|
|
|
|
(
|
|
|
|
({}, ["new"]),
|
|
|
|
({"simp": SIMPLE}, ["new", "simp"]),
|
|
|
|
({"nx": NON_EXCLUSIVE}, ["nx", "new"]),
|
|
|
|
({"nx": NON_EXCLUSIVE, "simp": SIMPLE}, ["nx", "new", "simp"]),
|
|
|
|
(
|
|
|
|
{"ctx1": NON_EXCLUSIVE, "ctx2": NON_EXCLUSIVE, "simp": SIMPLE},
|
|
|
|
["ctx1", "ctx2", "new", "simp"],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
{"ctx1": NON_EXCLUSIVE, "ctx2": NON_EXCLUSIVE, "simp": SIMPLE},
|
|
|
|
["ctx1", "ctx2", "new", "simp"],
|
|
|
|
),
|
|
|
|
(
|
|
|
|
{"ctx1": NON_EXCLUSIVE, "simp": SIMPLE, "ctx2": NON_EXCLUSIVE},
|
|
|
|
["ctx1", "new", "simp", "ctx2"],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2022-01-08 04:03:22 +05:30
|
|
|
def test_add_completer_start(monkeypatch, initial, exp, xession):
|
|
|
|
xession.completers.clear()
|
|
|
|
xession.completers.update(initial)
|
2021-05-30 09:42:55 +03:00
|
|
|
add_one_completer("new", SIMPLE, "start")
|
2022-01-08 04:03:22 +05:30
|
|
|
assert list(xession.completers.keys()) == exp
|