Skip to content

Commit

Permalink
Use an explicit list of valid pipx commands
Browse files Browse the repository at this point in the history
Rather than accessing a protected attribute of `parser._subparsers`

Note: a commented out line with the protected access is still included in the event that the list of valid pipx commands changes
  • Loading branch information
timacias authored Oct 4, 2024
1 parent b15dae8 commit c1c5a5b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,32 @@ def test_help(capsys):

def test_help_with_subcommands(capsys):
parser, _ = get_command_parser()
# The following line generates an attribute error from the linter, but executes normally
valid_commands = parser._subparsers._actions[4].choices.keys() # First four actions contain None
# The list of valid pipx commands was generated using the following line
# valid_commands = parser._subparsers._actions[4].choices.keys() # First four actions contain None
valid_commands = [
"install",
"install-all",
"uninject",
"inject",
"pin",
"unpin",
"upgrade",
"upgrade-all",
"upgrade-shared",
"uninstall",
"uninstall-all",
"reinstall",
"reinstall-all",
"list",
"interpreter",
"run",
"runpip",
"ensurepath",
"environment",
"help",
"completions",
]

for command in valid_commands:
try:
run_pipx_cli([command, "--help"])
Expand Down

0 comments on commit c1c5a5b

Please sign in to comment.