screen-locker/screen_locker/tests/_subset_coverage.py
Krzysztof kuhy Rudnicki a8c6177012
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (flutter, flutter-analyze, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint,flutter-analyze,dependency-freshness) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / lock-popup-safety (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (0) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (1) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (2) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (3) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (4) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (5) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (6) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (7) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (8) (push) Waiting to run
Tests / flutter test (shard ${{ matrix.shard }}) (9) (push) Waiting to run
Tests / flutter-coverage (push) Blocked by required conditions
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Skip the coverage bar on -k subset runs
pytest -q -k <name> (the board's done_check form) exited 1 on green
tests: fail_under = 100 judged a handful of tests against the whole
package. A pytest_sessionstart plugin clears pytest-cov's fail_under
when a keyword is given; whole-suite runs (commit gate, full_gate.sh,
CI) select none and keep the bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 13:49:14 +01:00

29 lines
1.0 KiB
Python

"""Hold only whole-suite runs to pyproject's ``fail_under = 100``.
A ``-k`` run selects a handful of tests, so its total coverage is always far
below 100% and pytest-cov turned every green ``pytest -q -k <name>`` (the
board's done_check form) into exit 1. The commit gate, the nightly
``full_gate.sh`` and CI select no keyword, so they keep the bar. Path-selected
partial runs (``test_changed.sh``, ``push_gate.sh``) pass ``--no-cov``
themselves and are untouched.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import pytest
def pytest_sessionstart(session: pytest.Session) -> None:
"""Drop the coverage bar for a ``-k`` keyword-selected run.
pytest-cov copies ``fail_under`` into its options when coverage starts
(before this hook) and checks it at the end; ``None`` skips the check.
"""
config = session.config
cov = config.pluginmanager.getplugin("_cov")
if cov is not None and config.option.keyword:
cov.options.cov_fail_under = None