feat(pytest): clear "pytest not installed" message
When collection finds nothing because pytest is missing on the host
interpreter, load() raises a dedicated message ("pytest is not installed
... pip install pytest") instead of the raw pytest output. The graceful
load mechanism surfaces it as a WARN at load + a clean FAIL at run, the
rest of the campaign keeps running.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -231,6 +231,13 @@ class TestItemPytestFile(TestItem):
|
||||
proc.wait()
|
||||
return nodeids, "\n".join(output)
|
||||
|
||||
def _collection_error(self, output):
|
||||
"""Clear reason why collection produced no test."""
|
||||
if "No module named pytest" in output:
|
||||
return ("pytest is not installed on the host interpreter used by "
|
||||
"testium (python_bin). Install it, e.g. 'pip install pytest'.")
|
||||
return 'No pytest test collected from "%s".\n%s' % (self._fileName, output)
|
||||
|
||||
def load(self):
|
||||
ret = {}
|
||||
if self._fileName == '':
|
||||
@@ -246,8 +253,7 @@ class TestItemPytestFile(TestItem):
|
||||
|
||||
nodeids, output = self._collect()
|
||||
if not nodeids:
|
||||
raise ETUMFileError(
|
||||
'No pytest test collected from "%s".\n%s' % (self._fileName, output))
|
||||
raise ETUMFileError(self._collection_error(output))
|
||||
|
||||
if self._test_methods:
|
||||
present = {nid.split("::")[-1].split("[")[0] for nid in nodeids}
|
||||
|
||||
Reference in New Issue
Block a user