Skip to content

FEAT Handle trial assertions through aggregate threshold evaluation#115

Open
behnam-o wants to merge 1 commit into
microsoft:mainfrom
behnam-o:assert-in-trials
Open

FEAT Handle trial assertions through aggregate threshold evaluation#115
behnam-o wants to merge 1 commit into
microsoft:mainfrom
behnam-o:assert-in-trials

Conversation

@behnam-o

Copy link
Copy Markdown

Trial clone assertion failures were reported as individual pytest failures, bypassing the trial group’s aggregate threshold.

This change intercepts assertion failures for @pytest.mark.trial calls, records missing outcomes as UNDETERMINED, and marks clones as passed so the aggregate threshold determines the final result. Successful trials without explicit results are recorded as SAFE. Non-trial assertions and non-assertion exceptions retain normal pytest behavior. Tests cover threshold outcomes, result deduplication, and failure preservation.

@behnam-o behnam-o requested a review from a team July 14, 2026 19:15
Comment on lines +432 to +445
if call.excinfo is None:
result = Result(
safe=True,
status=SafetyStatus.SAFE,
summary="Trial completed without recording a Result.",
)
else:
summary = str(call.excinfo.value) or "Trial assertion did not pass."
result = Result(
safe=False,
status=SafetyStatus.UNDETERMINED,
summary=summary,
)
collector.record(result=result)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part makes me a bit uneasy - would also have to check if we are forwarding all the other metadata fields like category, etc.

Comment on lines +486 to +490

_record_missing_trial_result(collector=collector, call=call)
report.outcome = "passed"
report.longrepr = None
return report

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also am not sure about how we want to think about the population number total reported by pytest: if I have a suite of 10 tests, with differing number of trials, we would potentially be weighting those tests as it currently stands - perhaps more thought about hooking into execution loop to run our own loop and then report to pytest just 1 result (akin to pytest-loop)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants