mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
tests: do not allow underscores in cli options
We use dashes in --long-options, not underscores, so add a test to make sure people don't accidentally add them. Change-Id: Iffbce474d22cf1f6c2042f7882f215875c8df3cf Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/369734 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
99ebf627db
commit
e7e20f4686
@ -75,3 +75,17 @@ class AllCommands(unittest.TestCase):
|
||||
msg=f"subcmds/{name}.py: {option.get_opt_string()}: "
|
||||
f'help text should not end in a period: "{option.help}"',
|
||||
)
|
||||
|
||||
def test_cli_option_style(self):
|
||||
"""Force some consistency in option flags."""
|
||||
for name, cls in subcmds.all_commands.items():
|
||||
cmd = cls()
|
||||
parser = cmd.OptionParser
|
||||
for option in parser.option_list:
|
||||
for opt in option._long_opts:
|
||||
self.assertNotIn(
|
||||
"_",
|
||||
opt,
|
||||
msg=f"subcmds/{name}.py: {opt}: only use dashes in "
|
||||
"options, not underscores",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user