Merge branch 'feat/graceful-item-load' into feat/pytest-item

# Conflicts:
#	DESIGN.md
This commit is contained in:
2026-06-14 20:23:08 +02:00
3 changed files with 24 additions and 1 deletions

View File

@@ -61,6 +61,13 @@ def test_run(f):
self.run_test_init()
# The item could not be loaded (e.g. a missing module): FAIL at run.
# run_test_end -> write_footer prints the message.
if self._load_error is not None:
self.result.set(TestValue.FAILURE, self._load_error)
self.run_test_end()
return self.result
while self._is_paused:
sleep(0.2)
if self.isStopped() :
@@ -151,6 +158,7 @@ class TestItem:
self._expected_result = None
self._no_fail = None
self._is_stopped = False
self._load_error = None
self._is_running = False
self._is_breakpoint = False
self._is_paused = False

View File

@@ -451,6 +451,20 @@ class TestSet:
def rootItem(self):
return self._rootItem
def _load_item(self, item):
"""Run an item's self-load, deferring a failure (e.g. a missing module)
to a run-time FAILURE instead of aborting the whole test load."""
try:
return item.load()
except Exception as e:
msg = getattr(e, "_message", None) or str(e)
item._load_error = msg
tm.print_warn(
f"'{item.cmd()}' item '{item.name()}' could not be loaded: "
f"{msg} (it will FAIL at run)."
)
return {}
def load_test_recursively(self, tree_parent, parent_seq, file_name):
ret = {}
try:
@@ -534,7 +548,7 @@ class TestSet:
# case where the test item loads itself its descendants
if it in (cst_type.TYPE_UNITTEST, cst_type.TYPE_PYTEST):
item.setTestDir(test_dir)
child = item.load()
child = self._load_item(item)
elif issubclass(it.item_class, TestItemActions):
child = item.load()
# case where the test item is an items container