MCPcopy Index your code
hub / github.com/python/cpython / testPartExecutor

Method testPartExecutor

Lib/unittest/case.py:54–83  ·  view source on GitHub ↗
(self, test_case, subTest=False)

Source from the content-addressed store, hash-verified

52
53 @contextlib.contextmanager
54 def testPartExecutor(self, test_case, subTest=False):
55 old_success = self.success
56 self.success = True
57 try:
58 yield
59 except KeyboardInterrupt:
60 raise
61 except SkipTest as e:
62 self.success = False
63 _addSkip(self.result, test_case, str(e))
64 except _ShouldStop:
65 pass
66 except:
67 exc_info = sys.exc_info()
68 if self.expecting_failure:
69 self.expectedFailure = exc_info
70 else:
71 self.success = False
72 if subTest:
73 self.result.addSubTest(test_case.test_case, test_case, exc_info)
74 else:
75 _addError(self.result, test_case, exc_info)
76 # explicitly break a reference cycle:
77 # exc_info -> frame -> exc_info
78 exc_info = None
79 else:
80 if subTest and self.success:
81 self.result.addSubTest(test_case.test_case, test_case, None)
82 finally:
83 self.success = self.success and old_success
84
85
86def _addSkip(result, test_case, reason):

Callers 3

subTestMethod · 0.80
runMethod · 0.80
doCleanupsMethod · 0.80

Calls 4

_addSkipFunction · 0.85
strFunction · 0.85
_addErrorFunction · 0.85
addSubTestMethod · 0.45

Tested by

no test coverage detected