xonsh/tests/completers/test_base_completer.py
Andy Kipp 6d0c23e16f
Close 4215: Added env variable to ignore ./ and ../ in filepath completion (#4241)
* Added env variable to ignore ./ and ../ in filepath completion

* Changed ignore_dots to complete dots as always, never, or upon matching

* Updated news

* Added default 'matching'

* Update ignore_dots.rst

* black

* fix test

* tests

Co-authored-by: Bailey Morgan <bailey.mccarty.morgan@gmail.com>
Co-authored-by: a <a@a.a>
2021-04-27 09:28:17 -04:00

43 lines
1 KiB
Python

import pytest
from tests.tools import ON_WINDOWS
from xonsh.completers.base import complete_base
from xonsh.parsers.completion_context import (
CompletionContext,
CommandContext,
CommandArg,
PythonContext,
)
CUR_DIR = "." if ON_WINDOWS else "./" # for some reason this is what happens in `complete_path`
@pytest.fixture(autouse=True)
def setup(xonsh_builtins, xonsh_execer, monkeypatch):
monkeypatch.setattr(xonsh_builtins.__xonsh__, "commands_cache", ["cool"])
def test_empty_line():
completions = complete_base(
CompletionContext(
command=CommandContext((), 0),
python=PythonContext("", 0)
)
)
assert completions
for exp in ["cool", "abs"]:
assert exp in completions
def test_empty_subexpr():
completions = complete_base(
CompletionContext(
command=CommandContext((), 0, subcmd_opening="$("),
python=None
)
)
assert completions
for exp in ["cool"]:
assert exp in completions
assert "abs" not in completions