Skip to content

Commit 5202e5f

Browse files
committed
Improve HTML coverage state contrast
1 parent 9c22d84 commit 5202e5f

4 files changed

Lines changed: 36 additions & 15 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ with the overall percentage, uses Python-first names, and groups compact
8383
single-line field rows under their type. Soft green and red rows distinguish
8484
covered and missing fields, and missing fields are also labeled in text so the
8585
state survives printing. In resolver mode, fields using ordinary attribute
86-
lookup can be shown as neutral `not counted` rows for context while remaining
87-
excluded from coverage totals. Checkboxes can hide fully covered types or reveal
88-
those excluded fields without JavaScript. For declarations inside the pytest
89-
project root, the type header shows the Python file and each field shows its
90-
definition line.
86+
lookup can be shown as muted yellow-gray `not counted` rows for context while
87+
remaining excluded from coverage totals. Checkboxes can hide fully covered
88+
types or reveal those excluded fields without JavaScript. For declarations
89+
inside the pytest project root, the type header shows the Python file and each
90+
field shows its definition line.
9191
Fields wired through an external resolver, resolver factory, lambda, or
9292
user-defined field extension also include a compact `via ...` hint. Ordinary
9393
inline methods and framework-generated fields remain unannotated, keeping the

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ Add a self-contained, responsive HTML reporter for Strawberry field coverage
66
with an overall score, compact single-line Python-first type and field rows,
77
covered and missing row states with text status labels, sticky scanning
88
context, non-obvious resolver and custom-extension hints, schema-definition
9-
locations, CSS-only report filters, neutral not-counted default fields,
9+
locations, CSS-only report filters, muted yellow-gray not-counted default fields,
1010
threshold status, dark mode, print styles, and pytest-xdist aggregation.

pytest_strawberry/html_report.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@
3333
--border-strong: rgb(24 24 27 / 20%);
3434
--accent: #be123c;
3535
--high: #15803d;
36-
--high-soft: #f0fdf4;
36+
--high-soft: #dcfce7;
3737
--medium: #a16207;
3838
--low: #b91c1c;
39-
--low-soft: #fef2f2;
39+
--low-soft: #fee2e2;
40+
--excluded: #78716c;
41+
--excluded-soft: #f5f5ed;
4042
--mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
4143
--column-row-height: 1.75rem;
4244
--cell-x: 0.5rem;
@@ -335,6 +337,10 @@
335337
--field-background: var(--low-soft);
336338
}
337339
340+
.field-row[data-status="excluded"] {
341+
--field-background: var(--excluded-soft);
342+
}
343+
338344
.field-row > * {
339345
padding: 0.375rem var(--cell-x);
340346
border-top: 1px solid var(--border);
@@ -363,6 +369,10 @@
363369
color: var(--text-muted);
364370
}
365371
372+
.field-row[data-status="excluded"] .field-status-cell {
373+
color: var(--excluded);
374+
}
375+
366376
.field-location,
367377
.field-resolution {
368378
color: var(--text-muted);
@@ -481,10 +491,12 @@
481491
--border-strong: rgb(244 244 245 / 20%);
482492
--accent: #fb7185;
483493
--high: #4ade80;
484-
--high-soft: rgb(74 222 128 / 7%);
494+
--high-soft: rgb(74 222 128 / 14%);
485495
--medium: #fbbf24;
486496
--low: #f87171;
487-
--low-soft: rgb(248 113 113 / 8%);
497+
--low-soft: rgb(248 113 113 / 14%);
498+
--excluded: #a8a29e;
499+
--excluded-soft: rgb(250 204 21 / 9%);
488500
}
489501
}
490502
@@ -497,8 +509,10 @@
497509
--text-muted: #52525b;
498510
--border: rgb(24 24 27 / 15%);
499511
--border-strong: rgb(24 24 27 / 30%);
500-
--high-soft: #f0fdf4;
501-
--low-soft: #fef2f2;
512+
--high-soft: #dcfce7;
513+
--low-soft: #fee2e2;
514+
--excluded: #57534e;
515+
--excluded-soft: #f5f5ed;
502516
}
503517
504518
.page {

tests/test_coverage.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,20 @@ def test_query() -> None:
209209
assert excluded_control is not None
210210
assert "checked" not in excluded_control.group("attributes")
211211
assert 'data-fully-covered="true"' in html
212-
assert 'data-status="excluded"' in html
212+
assert all(
213+
marker in html
214+
for marker in (
215+
'data-status="excluded"',
216+
"--excluded-soft: #f5f5ed;",
217+
'.field-row[data-status="excluded"] {',
218+
)
219+
)
213220
assert '<div class="type-columns" aria-hidden="true">' in html
214221
assert "<details" not in html
215222
assert 'class="type-header-row"' in html
216223
assert '<table class="field-table">' in html
217224
assert 'class="field-resolution"' not in html
218-
assert "Python type" not in html
219-
assert "Python field" not in html
225+
assert not any(label in html for label in ("Python type", "Python field"))
220226
assert ">Covered<" not in html
221227
assert ">Missing<" not in html
222228
assert 'aria-label="viewer, covered"' in html
@@ -226,6 +232,7 @@ def test_query() -> None:
226232
assert '<td class="field-status-cell">missing</td>' in html
227233
assert '<td class="field-status-cell">not counted</td>' in html
228234
assert html.count('<td class="field-status-cell"></td>') == _COVERED_FIELD_COUNT
235+
assert "--high-soft: #dcfce7;" in html
229236
assert 'class="summary-score" data-tone="medium"' in html
230237
assert "2/3 fields covered" in html
231238
assert 'class="schema-identity"' not in html

0 commit comments

Comments
 (0)