MCPcopy Index your code
hub / github.com/RustPython/RustPython / subTest

Method subTest

Lib/unittest/case.py:552–580  ·  view source on GitHub ↗

Return a context manager that will return the enclosed block of code in a subtest identified by the optional message and keyword parameters. A failure in the subtest marks the test case as failed but resumes execution at the end of the enclosed block, allowing furthe

(self, msg=_subtest_msg_sentinel, **params)

Source from the content-addressed store, hash-verified

550
551 @contextlib.contextmanager
552 def subTest(self, msg=_subtest_msg_sentinel, **params):
553 """Return a context manager that will return the enclosed block
554 of code in a subtest identified by the optional message and
555 keyword parameters. A failure in the subtest marks the test
556 case as failed but resumes execution at the end of the enclosed
557 block, allowing further test code to be executed.
558 """
559 if self._outcome is None or not self._outcome.result_supports_subtests:
560 yield
561 return
562 parent = self._subtest
563 if parent is None:
564 params_map = _OrderedChainMap(params)
565 else:
566 params_map = parent.params.new_child(params)
567 self._subtest = _SubTest(self, msg, params_map)
568 try:
569 with self._outcome.testPartExecutor(self._subtest, subTest=True):
570 yield
571 if not self._outcome.success:
572 result = self._outcome.result
573 if result is not None and result.failfast:
574 raise _ShouldStop
575 elif self._outcome.expectedFailure:
576 # If the test is expecting a failure, we really want to
577 # stop now and register the expected failure.
578 raise _ShouldStop
579 finally:
580 self._subtest = parent
581
582 def _addExpectedFailure(self, result, exc_info):
583 try:

Calls 4

_OrderedChainMapClass · 0.85
_SubTestClass · 0.85
new_childMethod · 0.80
testPartExecutorMethod · 0.80