mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
fix: argparse based completions should work in newer python versions (#5542)
PS.
e47ecbd042
fixes #5471
This commit is contained in:
parent
12aa885d7b
commit
fa254914d7
2 changed files with 25 additions and 1 deletions
|
@ -56,3 +56,27 @@ def test_skipper_arg(completion_context_parse, xession, monkeypatch):
|
|||
assert context.command == CommandContext(
|
||||
args=(CommandArg("grep"),), arg_index=1, prefix="--coun"
|
||||
)
|
||||
|
||||
|
||||
def test_argparse_completer(check_completer, monkeypatch):
|
||||
assert check_completer("xonsh", prefix="-").issuperset(
|
||||
{
|
||||
"--cache-everything",
|
||||
"--help",
|
||||
"--interactive",
|
||||
"--login",
|
||||
"--no-env",
|
||||
"--no-rc",
|
||||
"--no-script-cache",
|
||||
"--rc",
|
||||
"--shell-type",
|
||||
"--timings",
|
||||
"--version",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_argparse_completer_after_option(check_completer, tmp_path):
|
||||
prefix = str(tmp_path)[:-1]
|
||||
# has one or more completions including the above tmp_path
|
||||
assert check_completer("xonsh --no-rc", prefix)
|
||||
|
|
|
@ -545,7 +545,7 @@ class ArgparseCompleter:
|
|||
break
|
||||
# it is a valid option and advance
|
||||
self.remaining_args = self.remaining_args[1:]
|
||||
act, _, value = act_res
|
||||
act, *_, value = act_res
|
||||
|
||||
# remove the found option
|
||||
# todo: not remove if append/extend
|
||||
|
|
Loading…
Add table
Reference in a new issue