From 975ff1cdec8f9ef3f5cf1cd47759be3b06b317f6 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg Date: Tue, 17 Feb 2026 13:22:25 +0100 Subject: [PATCH] Remove subtests Also remove the dependency on the subtest pytest plugin. --- .github/workflows/test.yml | 4 +-- pulp-glue-gem/pyproject.toml | 2 +- pyproject.toml | 2 +- test_requirements.txt | 3 +-- tests/test_help_pages.py | 50 +++++++++++++++++++++--------------- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 31a06fa..0fb1b1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,12 +19,12 @@ jobs: include: - image_tag: "nightly" pulp_api_root: "/relocated/djnd/" - python: "3.11" + python: "3.14" upper_bounds: true - image_tag: "latest" lower_bounds: true pulp_https: true - python: "3.8" + python: "3.10" steps: - uses: "actions/checkout@v5" - uses: "actions/cache@v4" diff --git a/pulp-glue-gem/pyproject.toml b/pulp-glue-gem/pyproject.toml index 1bfdc0e..84b1a27 100644 --- a/pulp-glue-gem/pyproject.toml +++ b/pulp-glue-gem/pyproject.toml @@ -7,7 +7,7 @@ name = "pulp-glue-gem" version = "0.6.0.dev" description = "Version agnostic glue library to talk to pulpcore's REST API. (Gem plugin)" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.10" license = {text = "GPLv2+"} authors = [ {name = "Pulp Team", email = "pulp-list@redhat.com"}, diff --git a/pyproject.toml b/pyproject.toml index 635782d..8743a82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "pulp-cli-gem" version = "0.6.0.dev" description = "Command line interface to talk to pulpcore's REST API. (Gem plugin commands)" readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.10" license = {text = "GPLv2+"} authors = [ {name = "Pulp Team", email = "pulp-list@redhat.com"}, diff --git a/test_requirements.txt b/test_requirements.txt index cf97bb3..3802fb8 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,5 +1,4 @@ # Test requirements -pytest>=7.0.0,<=8.4.2 -pytest-subtests>=0.12.0,<=0.14.2 +pytest>=7.0.0,<=9.1.0 python-gnupg==0.5.5 trustme>=1.1.0,<1.3 diff --git a/tests/test_help_pages.py b/tests/test_help_pages.py index 739cd62..91be5ac 100644 --- a/tests/test_help_pages.py +++ b/tests/test_help_pages.py @@ -6,7 +6,6 @@ from packaging.version import parse as parse_version from pulp_cli import __version__ as PULP_CLI_VERSION from pulp_cli import load_plugins, main -from pytest_subtests.plugin import SubTests load_plugins() @@ -30,6 +29,20 @@ def traverse_commands(command: click.Command, args: t.List[str]) -> t.Iterator[t yield from traverse_commands(sub, args + ["--type", context_type, name]) +def pytest_generate_tests(metafunc: pytest.Metafunc) -> None: + m = next(metafunc.definition.iter_markers("help_page"), None) + if m is not None and "base_cmd" in m.kwargs: + if parse_version(PULP_CLI_VERSION) < parse_version("0.24"): + pytest.skip("This test is incompatible with older cli versions.") + rel_main: click.Group = main + base_cmd = m.kwargs["base_cmd"] + for step in base_cmd: + sub = rel_main.commands[step] + assert isinstance(sub, click.Group) + rel_main = sub + metafunc.parametrize("args", traverse_commands(rel_main, base_cmd), ids=" ".join) + + @pytest.fixture def no_api(monkeypatch: pytest.MonkeyPatch) -> None: @property # type: ignore @@ -39,24 +52,19 @@ def getter(self: t.Any) -> None: monkeypatch.setattr("pulp_glue.common.context.PulpContext.api", getter) -@pytest.mark.help_page -def test_access_help(no_api: None, subtests: SubTests) -> None: - """Test, that all help screens are accessible without touching the api property.""" - if parse_version(PULP_CLI_VERSION) < parse_version("0.24"): - pytest.skip("This test is incompatible with older cli versions.") - +@pytest.mark.help_page(base_cmd=["gem"]) +def test_accessing_the_help_page_does_not_invoke_api( + no_api: None, + args: list[str], +) -> None: runner = CliRunner() - for args in traverse_commands(main.commands["gem"], ["gem"]): - 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 - or "not available in this context" in result.stderr - ) - else: - assert result.exit_code == 0 - assert result.stdout.startswith("Usage:") or result.stdout.startswith( - "DeprecationWarning:" - ) + result = runner.invoke(main, args + ["--help"], catch_exceptions=False) + + if result.exit_code == 2: + assert ( + "not available in this context" in result.stdout + or "not available in this context" in result.stderr + ) + else: + assert result.exit_code == 0 + assert result.stdout.startswith("Usage:") or result.stdout.startswith("DeprecationWarning:")