Skip to content

Commit c1c5a5b

Browse files
authored
Use an explicit list of valid pipx commands
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
1 parent b15dae8 commit c1c5a5b

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

tests/test_help.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,32 @@ def test_help(capsys):
2020

2121
def test_help_with_subcommands(capsys):
2222
parser, _ = get_command_parser()
23-
# The following line generates an attribute error from the linter, but executes normally
24-
valid_commands = parser._subparsers._actions[4].choices.keys() # First four actions contain None
23+
# The list of valid pipx commands was generated using the following line
24+
# valid_commands = parser._subparsers._actions[4].choices.keys() # First four actions contain None
25+
valid_commands = [
26+
"install",
27+
"install-all",
28+
"uninject",
29+
"inject",
30+
"pin",
31+
"unpin",
32+
"upgrade",
33+
"upgrade-all",
34+
"upgrade-shared",
35+
"uninstall",
36+
"uninstall-all",
37+
"reinstall",
38+
"reinstall-all",
39+
"list",
40+
"interpreter",
41+
"run",
42+
"runpip",
43+
"ensurepath",
44+
"environment",
45+
"help",
46+
"completions",
47+
]
48+
2549
for command in valid_commands:
2650
try:
2751
run_pipx_cli([command, "--help"])

0 commit comments

Comments
 (0)