Skip to content

Commit 7b4a185

Browse files
committed
Stop using subtests
They were not necessary and add a dependency we don't want.
1 parent 8fb4e12 commit 7b4a185

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Test requirements
2-
pytest>=9.0.0,<9.1
2+
pytest>=7.0.0,<9.1
33
pytest-xdist
44
python-gnupg>=0.5.0,<0.6
55
trustme>=1.1.0,<1.3

tests/test_help_pages.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def traverse_commands(command: click.Command, args: t.List[str]) -> t.Iterator[t
2929
yield from traverse_commands(sub, args + ["--type", context_type, name])
3030

3131

32+
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
33+
m = next(metafunc.definition.iter_markers("help_page"), None)
34+
if m is not None and "base_cmd" in m.kwargs:
35+
metafunc.parametrize("args", traverse_commands(main, m.kwargs["base_cmd"]), ids=" ".join)
36+
37+
3238
@pytest.fixture
3339
def no_api(monkeypatch: pytest.MonkeyPatch) -> None:
3440
@property # type: ignore
@@ -38,30 +44,28 @@ def getter(self: t.Any) -> None:
3844
monkeypatch.setattr("pulp_glue.common.context.PulpContext.api", getter)
3945

4046

41-
@pytest.mark.help_page
42-
def test_access_help(no_api: None, subtests: pytest.Subtests) -> None:
43-
"""Test, that all help screens are accessible without touching the api property."""
47+
@pytest.mark.help_page(base_cmd=[])
48+
def test_accessing_the_help_page_does_not_invoke_api(
49+
no_api: None,
50+
args: list[str],
51+
) -> None:
4452
runner = CliRunner()
45-
for args in traverse_commands(main, []):
46-
with subtests.test(msg=" ".join(args)):
47-
result = runner.invoke(main, args + ["--help"], catch_exceptions=False)
48-
49-
if result.exit_code == 2:
50-
assert (
51-
"not available in this context" in result.stdout
52-
or "not available in this context" in result.stderr
53-
)
54-
else:
55-
assert result.exit_code == 0
56-
assert result.stdout.startswith("Usage:") or result.stdout.startswith(
57-
"DeprecationWarning:"
58-
)
53+
result = runner.invoke(main, args + ["--help"], catch_exceptions=False)
54+
55+
if result.exit_code == 2:
56+
assert (
57+
"not available in this context" in result.stdout
58+
or "not available in this context" in result.stderr
59+
)
60+
else:
61+
assert result.exit_code == 0
62+
assert result.stdout.startswith("Usage:") or result.stdout.startswith("DeprecationWarning:")
5963

6064

6165
@pytest.mark.parametrize(
6266
"command,options",
6367
[
64-
(
68+
pytest.param(
6569
[
6670
"file",
6771
"repository",

0 commit comments

Comments
 (0)