Skip to content

Commit

Permalink
Use subtests to group the help_page tests
Browse files Browse the repository at this point in the history
[noissue]
  • Loading branch information
mdellweg authored and ggainey committed Feb 17, 2023
1 parent c365648 commit de64a80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
1 change: 1 addition & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Test requirements
pygments
pytest
pytest-subtests
python-gnupg

# Lint requirements
Expand Down
21 changes: 12 additions & 9 deletions tests/test_help_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,17 @@ def getter(self):


@pytest.mark.help_page
@pytest.mark.parametrize("args", traverse_commands(main, []), ids=" ".join)
def test_access_help(no_api, args):
def test_access_help(no_api, subtests):
"""Test, that all help screens are accessible without touching the api property."""
runner = CliRunner()
result = runner.invoke(main, args + ["--help"], catch_exceptions=False)

if result.exit_code == 2:
assert "not available in this context" in result.stdout
else:
assert result.exit_code == 0
assert result.stdout.startswith("Usage:") or result.stdout.startswith("DeprecationWarning:")
for args in traverse_commands(main, []):
with subtests.test(msg=" ".join(args)):
result = runner.invoke(main, args + ["--help"], catch_exceptions=False)

if result.exit_code == 2:
assert "not available in this context" in result.stdout
else:
assert result.exit_code == 0
assert result.stdout.startswith("Usage:") or result.stdout.startswith(
"DeprecationWarning:"
)

0 comments on commit de64a80

Please sign in to comment.