|
| 1 | +# RegiLattice — Coverage Report |
| 2 | + |
| 3 | +> Per-module test coverage baseline. Last measured: 2026-03-08 · v1.0.1 |
| 4 | +> Command: `python -m pytest tests/ --cov=regilattice --cov-report=term-missing` |
| 5 | +
|
| 6 | +--- |
| 7 | + |
| 8 | +## Summary |
| 9 | + |
| 10 | +| Scope | Coverage | |
| 11 | +|---|---| |
| 12 | +| **Core modules (non-tweak)** | ~81 % average | |
| 13 | +| **Tweak modules (apply/remove/detect fns)** | ~49 % average (intentionally limited — registry calls are not exercised in CI) | |
| 14 | +| **Overall total** | ~51 % | |
| 15 | + |
| 16 | +The low overall percentage is dominated by the 69 tweak category modules, where |
| 17 | +the `_apply_*` / `_remove_*` / `_detect_*` functions touch real registry keys |
| 18 | +and are intentionally **not** invoked in automated tests. All tweak signatures, |
| 19 | +IDs, and `detect_fn` callability are verified via `test_tweaks_smoke.py`. |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Core Module Coverage |
| 24 | + |
| 25 | +| Module | Statements | Missed | Coverage | Notes | |
| 26 | +|---|---|---|---|---| |
| 27 | +| `__init__.py` | 5 | 0 | **100 %** | ✅ | |
| 28 | +| `analytics.py` | 61 | 0 | **100 %** | ✅ | |
| 29 | +| `config.py` | 50 | 5 | **90 %** | tomllib fallback path (Python < 3.11) | |
| 30 | +| `corpguard.py` | 252 | 62 | **75 %** | VPN / SCCM detection paths | |
| 31 | +| `deps.py` | 73 | 0 | **100 %** | ✅ | |
| 32 | +| `elevation.py` | 44 | 2 | **95 %** | Non-Windows uid path | |
| 33 | +| `gui.py` | 1096 | 955 | **13 %** | 🔴 Highest priority — needs GUI test harness | |
| 34 | +| `gui_dialogs.py` | 171 | 76 | **56 %** | Dialog show/interact paths | |
| 35 | +| `gui_theme.py` | 97 | 2 | **98 %** | ✅ | |
| 36 | +| `gui_tooltip.py` | 97 | 25 | **74 %** | `Tooltip.show()` visual paths | |
| 37 | +| `gui_widgets.py` | 241 | 138 | **43 %** | 🔴 Widget event handlers | |
| 38 | +| `hwinfo.py` | 280 | 5 | **98 %** | ✅ | |
| 39 | +| `locale.py` | 28 | 0 | **100 %** | ✅ | |
| 40 | +| `marketplace.py` | 75 | 4 | **95 %** | ✅ | |
| 41 | +| `menu.py` | 166 | 11 | **93 %** | ✅ | |
| 42 | +| `ratings.py` | 60 | 2 | **97 %** | ✅ | |
| 43 | +| `registry.py` | 361 | 56 | **84 %** | Backup dir / edge cases | |
| 44 | +| `cli.py` | 572 | 77 | **87 %** | `--gui`, export edge cases | |
| 45 | +| `tweaks/__init__.py` | ~800 | ~80 | **~90 %** | ✅ Core engine well-covered | |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Tweak Module Coverage (average ~49 %) |
| 50 | + |
| 51 | +The low coverage in tweak modules is **by design**: |
| 52 | + |
| 53 | +- `_apply_*` and `_remove_*` functions call `winreg.SetValueEx` / `winreg.DeleteValue`, |
| 54 | + which require a real Windows registry and admin rights. |
| 55 | +- These are tested in integration tests on a CI runner with registry access. |
| 56 | +- `detect_fn` callability is validated in `test_tweaks_smoke.py`. |
| 57 | + |
| 58 | +| Module | Coverage | Notes | |
| 59 | +|---|---|---| |
| 60 | +| `tweaks/accessibility.py` | ~51 % | Apply/remove paths uncovered | |
| 61 | +| `tweaks/explorer.py` | ~42 % | Largest module (504 stmts) | |
| 62 | +| `tweaks/shell.py` | ~35 % | Complex multi-step tweaks | |
| 63 | +| `tweaks/win11.py` | ~43 % | Large module (376 stmts) | |
| 64 | +| `tweaks/wsl.py` | ~44 % | WSL integration paths | |
| 65 | +| *(all others)* | 40–63 % | Pattern consistent across categories | |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## Coverage Targets |
| 70 | + |
| 71 | +| Target | Current | Goal | Priority | |
| 72 | +|---|---|---|---| |
| 73 | +| `gui.py` | 13 % | ≥ 80 % | 🔴 P1 (Sprint 4) | |
| 74 | +| `gui_widgets.py` | 43 % | ≥ 80 % | 🔴 P1 (Sprint 4) | |
| 75 | +| `gui_dialogs.py` | 56 % | ≥ 80 % | 🟡 P2 (Sprint 4) | |
| 76 | +| `corpguard.py` | 75 % | ≥ 90 % | 🟡 P2 (Sprint 4) | |
| 77 | +| `registry.py` | 84 % | ≥ 95 % | 🟡 P2 (Sprint 4) | |
| 78 | +| `gui_tooltip.py` | 74 % | ≥ 90 % | 🟡 P2 (Sprint 4) | |
| 79 | +| Overall (non-tweak) | ~81 % | ≥ 95 % | P1 | |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Running Coverage Locally |
| 84 | + |
| 85 | +```powershell |
| 86 | +# Full report with missing lines |
| 87 | +python -m pytest tests/ --cov=regilattice --cov-report=term-missing |
| 88 | +
|
| 89 | +# HTML report (open htmlcov/index.html) |
| 90 | +python -m pytest tests/ --cov=regilattice --cov-report=html |
| 91 | +
|
| 92 | +# Coverage for a specific module only |
| 93 | +python -m pytest tests/test_registry.py --cov=regilattice.registry --cov-report=term-missing |
| 94 | +``` |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +## Improving Coverage |
| 99 | + |
| 100 | +### GUI modules (`gui.py`, `gui_widgets.py`, `gui_dialogs.py`) |
| 101 | + |
| 102 | +Use `unittest.mock.patch` with `tkinter` mocked: |
| 103 | + |
| 104 | +```python |
| 105 | +import sys |
| 106 | +from unittest.mock import MagicMock, patch |
| 107 | + |
| 108 | +# Mock the entire tkinter module before importing gui |
| 109 | +sys.modules["tkinter"] = MagicMock() |
| 110 | +sys.modules["tkinter.ttk"] = MagicMock() |
| 111 | +sys.modules["tkinter.messagebox"] = MagicMock() |
| 112 | + |
| 113 | +from regilattice import gui |
| 114 | +``` |
| 115 | + |
| 116 | +### Registry modules (apply/remove/detect) |
| 117 | + |
| 118 | +Use the `dry_session` pytest fixture from `conftest.py`: |
| 119 | + |
| 120 | +```python |
| 121 | +def test_apply_tweak(dry_session, monkeypatch): |
| 122 | + from regilattice.registry import SESSION |
| 123 | + monkeypatch.setattr("regilattice.tweaks.explorer.SESSION", dry_session) |
| 124 | + from regilattice.tweaks.explorer import _apply_show_extensions |
| 125 | + _apply_show_extensions(require_admin=False) |
| 126 | + assert dry_session._write_log # verify a write was recorded |
| 127 | +``` |
0 commit comments