Consolidate class-level error record finalization in BaseTestClass - #1032
Merged
Merged
Conversation
- Introduce BaseTestClass._record_class_error() to unify the 6 class-level error record finalization sites across _pre_run, _setup_class, _teardown_class, and _clean_up. - Ensure record.test_error() and record.update_record() are always invoked prior to _exec_procedure_func(self._on_fail, record) so that on_fail consistently receives a record with populated end_time and details (including when setup_class fails via expects). - Wrap _on_fail execution in try/finally so that results.add_class_error() and summary_writer.dump() are guaranteed to execute even if on_fail raises an abort signal such as asserts.abort_all(). Fixes #1029
|
I've confirmed that this resolves my issue! Thanks! |
ko1in1u
approved these changes
Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1029.
Consolidates all 6 class-level error record finalization sites (
_pre_run,_setup_classexception &expectsbranches,_teardown_classexception &expectsbranches, and_clean_up) into a single helper methodBaseTestClass._record_class_error().Problem
abort_all()inon_fail(Issuesetup_classerror record is not written totest_summary.yamlwhenon_failraisesTestAbortAll#1029):When
setup_classfails (via an uncaught exception orexpects) andon_failraises an abort signal (asserts.abort_all()/asserts.abort_class()),summary_writer.dump()(andresults.add_class_error()in theexpectspath) were skipped because they appeared afterself._exec_procedure_func(self._on_fail, class_record)without atry...finallyguard.end_timeanddetailsinsideon_failforsetup_classexpectsfailures:In
_setup_class, theif expects.recorder.has_error:block previously invokedself._exec_procedure_func(self._on_fail, class_record)beforeclass_record.test_error()andclass_record.update_record(). As a result,record.end_timeandrecord.detailswereNoneinsideon_fail(unlike normal test failures inexec_one_testor uncaught exceptions in_setup_class).Solution
Introduce
_record_class_error(self, record, e=None, exec_on_fail=False)which enforces a canonical lifecycle across all class stages:record.test_error(e)andrecord.update_record()before runningon_failsorecord.end_time,record.termination_signal, andrecord.detailsare always populated whenon_failexecutes._exec_procedure_func(self._on_fail, record)inside atry...finallyblock so thatself.results.add_class_error(record)andself.summary_writer.dump(...)always execute even ifon_failraises an abort signal.