Skip to content

Commit

Permalink
Merge pull request #1123 from mulkieran/test-all-help-text
Browse files Browse the repository at this point in the history
Print help text for every command
  • Loading branch information
mulkieran authored Jan 16, 2025
2 parents 3e4645d + f69380a commit 6973e51
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/whitebox/integration/test_help_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Copyright 2025 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Test that printing out help text does not result in any error returns or
exceptions.
"""

# isort: STDLIB
from argparse import _SubParsersAction

# isort: LOCAL
from stratis_cli._parser import gen_parser

from ._misc import RunTestCase


def gen_subcommands(parser, command_line):
"""
Recursively traverse the parser, yielding all possible subcommands.
"""
yield command_line
for action in (
action
for action in parser._actions # pylint: disable=protected-access
if isinstance(action, _SubParsersAction)
):
for name, subparser in action.choices.items():
yield from gen_subcommands(subparser, command_line + [name])


class ParserHelpTestCase(RunTestCase):
"""
Test various timeout inputs.
"""

def test_help(self):
"""
Test all parser help.
"""

for command_line in gen_subcommands(gen_parser(), []):
self.check_system_exit(command_line + ["--help"], 0)

0 comments on commit 6973e51

Please sign in to comment.