I am hoping to get Bash autocompletion to work with pytest. That is, suppose that I have a pytest file test_foo.py whose content is
def test_case_simple():
pass
then entering pytest test_foo.py:: and pressing tab would give me test_case_simple. I know that Get pytest autocompletion in zshell is a related question but I am unable to get the same script working for bash (it gives me an error saying that compadd is unknown).
Followup: The script that I used is
#compdef pytest
_pytest_complete() {
local curcontext="$curcontext" state line
typeset -A opt_args
compadd "$@" $( pytest --collect-only -q | head -n -2)
}
_pytest_complete "$@"
and the error I got is
compadd: command not found