MCPcopy
hub / github.com/pytest-dev/pytest / _obtain_errors_and_skips

Method _obtain_errors_and_skips

src/_pytest/unittest.py:483–505  ·  view source on GitHub ↗

Compute or obtain the cached values for subtest errors and non-subtest skips.

(self)

Source from the content-addressed store, hash-verified

481 self.addSkip(testcase, reason, handle_subtests=False)
482
483 def _obtain_errors_and_skips(self) -> tuple[list[Any], list[Any]]:
484 """Compute or obtain the cached values for subtest errors and non-subtest skips."""
485 from unittest.case import _SubTest # type: ignore[attr-defined]
486
487 assert sys.version_info < (3, 11), (
488 "This workaround only should be used in Python 3.10"
489 )
490 if self._cached_errors_and_skips is not None:
491 return self._cached_errors_and_skips
492
493 subtest_errors = [
494 (x, y)
495 for x, y in self.instance._outcome.errors
496 if isinstance(x, _SubTest) and y is not None
497 ]
498
499 non_subtest_skips = [
500 (x, y)
501 for x, y in self.instance._outcome.skipped
502 if not isinstance(x, _SubTest)
503 ]
504 self._cached_errors_and_skips = (subtest_errors, non_subtest_skips)
505 return subtest_errors, non_subtest_skips
506
507
508@hookimpl(tryfirst=True)

Callers 2

addSkipMethod · 0.95
addSubTestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected