Skip to content

Commit

Permalink
test_ui: Fix spurious warnings in completion test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
wisp3rwind committed Jun 24, 2023
1 parent 854fec2 commit 7a279fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions beets/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,20 +1828,20 @@ def config_edit():
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):
Expand Down
2 changes: 1 addition & 1 deletion test/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from beets import plugins
from confuse import ConfigError
from beets import util
from beets.util import syspath, MoveOperation
from beets.util import displayable_path, syspath, MoveOperation


class ListTest(unittest.TestCase):
Expand Down

0 comments on commit 7a279fb

Please sign in to comment.