mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00

* todo: * refactor: remove usage of singleton in cmd-cache * refactor: pass aliases/env to commands_cache on creation reduce the usage of singletons * fix: setting up mockups for tests * feat: add $XONSH_CACHE_DIR * refactor: use cache path to stire cmds-cache * chore: todo * feat: efficient cache commands per path and modified time * refactor: move aliases to commands cache now XonshSession is not needed to setup cmds-cache * refactor: update tests * fix: type annotation * refactor: init aliases at commands-cache * test: update failing tests * fix: handle paths mtime changing * docs: add news item * refactor: remove $COMMANDS_CACHE_SIZE_WARNING * fix: loading on windows fails because of setup sequence * fix: failing tests
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import pytest
|
|
|
|
from xonsh.completers.base import complete_base
|
|
from xonsh.parsers.completion_context import CommandContext, CompletionContext
|
|
from xonsh.pytest.tools import ON_WINDOWS
|
|
|
|
CUR_DIR = (
|
|
"." if ON_WINDOWS else "./"
|
|
) # for some reason this is what happens in `complete_path`
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def setup(xession, xonsh_execer, monkeypatch, mock_executables_in):
|
|
xession.env["COMMANDS_CACHE_SAVE_INTERMEDIATE"] = False
|
|
xession.env["COMPLETION_QUERY_LIMIT"] = 2000
|
|
|
|
mock_executables_in(["cool"])
|
|
|
|
|
|
def test_empty_line(check_completer):
|
|
completions = check_completer("")
|
|
|
|
assert completions
|
|
assert completions.issuperset({"cool", "abs"})
|
|
for exp in ["cool", "abs"]:
|
|
assert exp in completions
|
|
|
|
|
|
def test_empty_subexpr():
|
|
completions = complete_base(
|
|
CompletionContext(
|
|
command=CommandContext((), 0, subcmd_opening="$("), python=None
|
|
)
|
|
)
|
|
completions = set(map(str, completions))
|
|
assert completions
|
|
assert completions.issuperset({"cool"})
|
|
assert "abs" not in completions
|