Datasets:
File size: 2,005 Bytes
0e239c6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | """Admission guards for complete pytest evidence and world/repeat coverage."""
def report_health(report, expected_ids=None):
if not isinstance(report, dict):
return ['Missing pytest report']
issues = []
ids = report.get('collected', [])
if not ids or len(ids) != len(set(ids)):
issues.append('Empty or duplicate case collection')
if report.get('testscollected') != len(ids):
issues.append('Collection count mismatch')
if expected_ids is not None and set(ids) != set(expected_ids):
issues.append('Case inventory drift')
if report.get('collection_errors') or report.get('internal_errors'):
issues.append('Collection or internal error')
reports = report.get('reports', [])
if set(x.get('nodeid') for x in reports) != set(ids):
issues.append('Case report coverage mismatch')
calls = []
for nodeid in ids:
phases = [x for x in reports if x.get('nodeid') == nodeid]
if sorted(x.get('when', '') for x in phases) != ['call', 'setup', 'teardown']:
issues.append(f'Incomplete/duplicate phases: {nodeid}')
for p in phases:
if p.get('when') == 'call':
calls.append(p.get('outcome'))
if p.get('outcome') not in ('passed', 'failed') or p.get('wasxfail'):
issues.append(f'Skipped/xfail/unknown case: {nodeid}')
elif p.get('outcome') != 'passed':
issues.append(f'Setup/teardown error: {nodeid}')
expected_exit = 1 if 'failed' in calls else 0
if report.get('exitstatus') != expected_exit:
issues.append('Exit status disagrees with case outcomes')
return issues
def matrix_health(runs, worlds, repeats):
from collections import Counter
actual = Counter((r.get('world'), r.get('repeat')) for r in runs)
expected = Counter((w, n) for w in worlds for n in range(1, repeats + 1))
return [] if actual == expected else ['Missing, duplicate or unexpected world/repeat']
|