screen-locker/screen_locker/tests/test_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

41 lines
1.6 KiB
Python

"""A ``-k`` run is a subset: the 100% coverage bar is for whole-suite runs.
The board's done_checks are ``pytest -q -k <name>``; with ``fail_under = 100``
in pyproject every one of them exited 1 on green tests (2026-11-23).
"""
from __future__ import annotations
from types import SimpleNamespace
from screen_locker.tests import _subset_coverage
def _config(keyword: str, fail_under: float | None) -> SimpleNamespace:
cov = SimpleNamespace(options=SimpleNamespace(cov_fail_under=fail_under))
manager = SimpleNamespace(getplugin=lambda name: cov if name == "_cov" else None)
return SimpleNamespace(
option=SimpleNamespace(keyword=keyword), pluginmanager=manager
)
def test_keyword_run_drops_the_coverage_bar() -> None:
"""``-k name`` selects a subset: its coverage is not held to fail_under."""
config = _config("preview_review_sequence", 100)
_subset_coverage.pytest_sessionstart(SimpleNamespace(config=config))
assert config.pluginmanager.getplugin("_cov").options.cov_fail_under is None
def test_whole_suite_keeps_the_coverage_bar() -> None:
"""No ``-k``: the commit gate's full run still needs 100%."""
config = _config("", 100)
_subset_coverage.pytest_sessionstart(SimpleNamespace(config=config))
assert config.pluginmanager.getplugin("_cov").options.cov_fail_under == 100
def test_no_coverage_plugin_is_left_alone() -> None:
"""``--no-cov`` or ``-p no:cov``: nothing to relax, no crash."""
manager = SimpleNamespace(getplugin=lambda _name: None)
config = SimpleNamespace(option=SimpleNamespace(keyword="x"), pluginmanager=manager)
_subset_coverage.pytest_sessionstart(SimpleNamespace(config=config))