mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
added tests for completion
command (for bash and zsh)
This commit is contained in:
parent
0998217cac
commit
c5d006d520
42
tests/test_completion.py
Normal file
42
tests/test_completion.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from test_pip import here, reset_env, run_pip, pyversion, lib_py
|
||||
from test_pip import write_file
|
||||
|
||||
def test_completion_for_bash():
|
||||
"""
|
||||
Test getting completion for bash shell
|
||||
"""
|
||||
reset_env()
|
||||
bash_completion = """\
|
||||
_pip_completion()
|
||||
{
|
||||
COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \\
|
||||
COMP_CWORD=$COMP_CWORD \\
|
||||
PIP_AUTO_COMPLETE=1 $1 ) )
|
||||
}
|
||||
complete -o default -F _pip_completion pip"""
|
||||
|
||||
result = run_pip('completion', '--bash')
|
||||
assert bash_completion in result.stdout, "bash completion is wrong"
|
||||
|
||||
|
||||
|
||||
def test_completion_for_zsh():
|
||||
"""
|
||||
Test getting completion for zsh shell
|
||||
"""
|
||||
reset_env()
|
||||
zsh_completion = """\
|
||||
function _pip_completion {
|
||||
local words cword
|
||||
read -Ac words
|
||||
read -cn cword
|
||||
reply=( $( COMP_WORDS="$words[*]" \\
|
||||
COMP_CWORD=$(( cword-1 )) \\
|
||||
PIP_AUTO_COMPLETE=1 $words[1] ) )
|
||||
}
|
||||
compctl -K _pip_completion pip"""
|
||||
|
||||
result = run_pip('completion', '--zsh')
|
||||
assert zsh_completion in result.stdout, "zsh completion is wrong"
|
||||
|
||||
|
Loading…
Reference in a new issue