Skip to content

Fix contradictory --fail-under failure messages - #2299

Open
qinpei-dev wants to merge 2 commits into
coveragepy:mainfrom
qinpei-dev:fix/fail-under-accurate-message
Open

qinpei-dev wants to merge 2 commits into
coveragepy:mainfrom
qinpei-dev:fix/fail-under-accurate-message

Conversation

@qinpei-dev

Copy link
Copy Markdown

Summary

  • Show the same rounded coverage total used by should_fail_under() in failure messages.
  • Preserve the unrounded total for the special 100% threshold and display the threshold without losing significant digits.
  • Add regression cases for near-zero coverage, near-100% coverage, and threshold precision.

Fixes #2295.

Tests

  • python -m pytest -q -o addopts='' tests/test_cmdline.py tests/test_results.py (131 passed)
  • ruff check coverage/cmdline.py
  • ruff check tests/test_cmdline.py --ignore E722 (existing unrelated bare except)
  • ruff format --check coverage/cmdline.py tests/test_cmdline.py
  • git diff --check

This branch has not been deployed

No deployments
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.

--fail-under prints a self-contradictory failure message

1 participant