test_ui: Fix spurious warnings in completion test

probably an issue going back to the Python 2 -> 3 switch: `map` gives an
iterator nowadays so after the test case started iterating
BASH_COMPLETION_PATHS, print_completion() couldn't find the
(previously found) bash_completion anymore, and would log a spurious
warning about that.

Also, some cleaup of path type handling
This commit is contained in:
wisp3rwind 2023-06-24 11:06:50 +02:00
parent 854fec2634
commit 26faf8daa9

View file

@ -1828,20 +1828,20 @@ default_commands.append(config_cmd)
def print_completion(*args):
for line in completion_script(default_commands + plugins.commands()):
print_(line, end='')
if not any(map(os.path.isfile, BASH_COMPLETION_PATHS)):
if not any(os.path.isfile(syspath(p)) for p in BASH_COMPLETION_PATHS):
log.warning('Warning: Unable to find the bash-completion package. '
'Command line completion might not work.')
BASH_COMPLETION_PATHS = map(syspath, [
'/etc/bash_completion',
'/usr/share/bash-completion/bash_completion',
'/usr/local/share/bash-completion/bash_completion',
BASH_COMPLETION_PATHS = [
b'/etc/bash_completion',
b'/usr/share/bash-completion/bash_completion',
b'/usr/local/share/bash-completion/bash_completion',
# SmartOS
'/opt/local/share/bash-completion/bash_completion',
b'/opt/local/share/bash-completion/bash_completion',
# Homebrew (before bash-completion2)
'/usr/local/etc/bash_completion',
])
b'/usr/local/etc/bash_completion',
]
def completion_script(commands):