Skip to content

Chore: register the unmute_click pytest marker (Part 2/2) - #52

Open
AmaadMartin wants to merge 1 commit into
fix/telemetry-cli-no-subcommand-exit-code-assertionfrom
chore/register-unmute-click-pytest-marker
Open

Chore: register the unmute_click pytest marker (Part 2/2)#52
AmaadMartin wants to merge 1 commit into
fix/telemetry-cli-no-subcommand-exit-code-assertionfrom
chore/register-unmute-click-pytest-marker

Conversation

@AmaadMartin

Copy link
Copy Markdown
Owner

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

  1. Link to an existing issue (if applicable):
    Closes: #issue_number
    Related: #issue_number
  2. Or, if no issue exists, describe the change:

Problem: tests/unittests/cli/utils/test_cli_tools_click.py applies
@pytest.mark.unmute_click nine times (L1640, L1696, L1732, L1766, L1800,
L1837, L1867, L1911, L1949), and its autouse _mute_click fixture reads it at
L83-L86 to let a test opt out of the click.echo mute. The marker is registered
nowhere, so every run of that file emits nine warnings:

PytestUnknownMarkWarning: Unknown pytest.mark.unmute_click - is this a typo?
You can register custom marks to avoid this warning

Solution: Register the marker in the existing [tool.pytest] table in
pyproject.toml, keeping the dotted ini_options.* key style already used
there. This is the canonical one-key fix — no conftest.py pytest_configure
hook, no new file.

No other marker in the repo is registered, so this introduces the markers key
for the first time; it is purely additive. It does not enable
--strict-markers, so it cannot make a previously-passing test fail — the only
observable effect is pytest's warning output.

Key placement (after ini_options.testpaths, before the asyncio_* keys) is
what pyproject-fmt 2.24.0 — the version pinned in .pre-commit-config.yaml
requires; pyproject-fmt --check pyproject.toml reports no change.

Stacking: this is part 2 of 2, based on
fix/telemetry-cli-no-subcommand-exit-code-assertion (#51), which fixes a stale
exit-code assertion in the same test file. The two were split on review because
they are independent concerns: the nine marker usages and the _mute_click
fixture both pre-date either branch (added in 6bab08fc), so this registration
stands on its own. It is stacked rather than parallel only so its CI reflects a
tree where the sibling failure is already fixed.

Collision check: ran gh pr list --state open --limit 100 on this fork (48
open PRs) and diffed the file lists of every plausibly adjacent one. Three
(#17, #25, #31) touch pyproject.toml, but their hunks are dependency additions
and a [tool.codespell] table — none registers pytest markers or touches
[tool.pytest]. No collision.

Testing Plan

Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.

Unit Tests:
[x] I have added or updated unit tests for my change.
[x] All unit tests pass locally.

This is a pytest configuration change and adds no production line, so it has no
new code to cover. It is verified by the existing suite plus a direct check that
the warning is gone.

Run locally on the exact pushed commit (Python 3.13, uv sync --extra test ->
click==8.4.2):

pytest tests/unittests/cli/utils/test_cli_tools_click.py -q        # 52 passed
pytest tests/unittests/cli -q                                      # 564 passed, 5 skipped
pytest tests/unittests/cli/utils/test_cli_tools_click.py -q 2>&1 \
  | grep -c PytestUnknownMarkWarning                               # 0  (was 9)

Proving the change is load-bearing. Making the warning an error turns the
registration into a pass/fail gate, and the branch was run both with and without
the hunk:

pytest tests/unittests/cli/utils/test_cli_tools_click.py -q \
  -W "error::pytest.PytestUnknownMarkWarning"
Tree Result
with the ini_options.markers hunk 52 passed
hunk reverted (git stash push pyproject.toml) ERROR ... pytest.PytestUnknownMarkWarning / Interrupted: 1 error during collection

Lint checks run locally against the changed file, at the pinned
.pre-commit-config.yaml versions:

pyproject-fmt==2.24.0 --check pyproject.toml   # no change for pyproject.toml
codespell==2.4.2 pyproject.toml                # clean

Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.

uv sync --extra test
# Before this change: nine PytestUnknownMarkWarning lines.
# After: zero, and the marked tests still opt out of the click mute.
pytest tests/unittests/cli/utils/test_cli_tools_click.py -q 2>&1 \
  | grep -c PytestUnknownMarkWarning

The marker still functions — test_telemetry_first_run_prompt_opt_in and its
siblings assert on prompt text that is only visible because _mute_click
honours the marker and skips the click.echo patch. Those assertions pass, so
registration did not change the marker's behaviour.

Expected CI status: absent, validated locally instead. The workflow triggers
on pull_request: branches: [main, v1]
(.github/workflows/continuous-integration.yml:25-31), and this PR's base is
fix/telemetry-cli-no-subcommand-exit-code-assertion, so no test job will run.
The commands and results recorded above were run on the exact pushed commit.

For reference, the Pre-commit Linter job also fails on this fork for a
pre-existing, unrelated reason — the update-constraints hook errors with
Resolution failed even without constraints on every PR, including ones that
touch no pyproject.toml (e.g. #45).

Checklist

[x] I have read the CONTRIBUTING.md document.
[x] I have performed a self-review of my own code.
[x] I have commented my code, particularly in hard-to-understand areas.
[x] I have added tests that prove my fix is effective or that my feature works.
[x] New and existing unit tests pass locally with my changes.

`tests/unittests/cli/utils/test_cli_tools_click.py` applies
`@pytest.mark.unmute_click` nine times, and its autouse `_mute_click` fixture
reads it, but the marker was never registered. Every run emitted nine
`PytestUnknownMarkWarning`s.

Register it in the existing `[tool.pytest]` table. This only affects pytest's
warning output; `--strict-markers` stays off, so no previously-passing test
can start failing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant