diff options
author | Mike Frysinger <vapier@google.com> | 2023-04-18 00:05:53 -0400 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-19 02:53:37 +0000 |
commit | e7e20f4686e1be6a3914df0a5ec60c7d32ba8775 (patch) | |
tree | f8d41dda166ad8cc2ab0a575e8bdf7e74ad50466 | |
parent | 99ebf627dbf50ea18935a3ab59e3c51fb41b7f77 (diff) | |
download | git-repo-e7e20f4686e1be6a3914df0a5ec60c7d32ba8775.tar.gz |
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>
-rw-r--r-- | tests/test_subcmds.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_subcmds.py b/tests/test_subcmds.py index 73b66e3f..5ce0776f 100644 --- a/tests/test_subcmds.py +++ b/tests/test_subcmds.py | |||
@@ -75,3 +75,17 @@ class AllCommands(unittest.TestCase): | |||
75 | msg=f"subcmds/{name}.py: {option.get_opt_string()}: " | 75 | msg=f"subcmds/{name}.py: {option.get_opt_string()}: " |
76 | f'help text should not end in a period: "{option.help}"', | 76 | f'help text should not end in a period: "{option.help}"', |
77 | ) | 77 | ) |
78 | |||
79 | def test_cli_option_style(self): | ||
80 | """Force some consistency in option flags.""" | ||
81 | for name, cls in subcmds.all_commands.items(): | ||
82 | cmd = cls() | ||
83 | parser = cmd.OptionParser | ||
84 | for option in parser.option_list: | ||
85 | for opt in option._long_opts: | ||
86 | self.assertNotIn( | ||
87 | "_", | ||
88 | opt, | ||
89 | msg=f"subcmds/{name}.py: {opt}: only use dashes in " | ||
90 | "options, not underscores", | ||
91 | ) | ||