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

Method test_sys_exit

Lib/test/_test_multiprocessing.py:1130–1168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1128
1129 @warnings_helper.ignore_fork_in_thread_deprecation_warnings()
1130 def test_sys_exit(self):
1131 # See Issue 13854
1132 if self.TYPE == 'threads':
1133 self.skipTest('test not appropriate for {}'.format(self.TYPE))
1134
1135 testfn = os_helper.TESTFN
1136 self.addCleanup(os_helper.unlink, testfn)
1137
1138 for reason in (
1139 [1, 2, 3],
1140 'ignore this',
1141 ):
1142 p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
1143 p.daemon = True
1144 p.start()
1145 join_process(p)
1146 self.assertEqual(p.exitcode, 1)
1147
1148 with open(testfn, encoding="utf-8") as f:
1149 content = f.read()
1150 self.assertEqual(content.rstrip(), str(reason))
1151
1152 os.unlink(testfn)
1153
1154 cases = [
1155 ((True,), 1),
1156 ((False,), 0),
1157 ((8,), 8),
1158 ((None,), 0),
1159 ((), 0),
1160 ]
1161
1162 for args, expected in cases:
1163 with self.subTest(args=args):
1164 p = self.Process(target=sys.exit, args=args)
1165 p.daemon = True
1166 p.start()
1167 join_process(p)
1168 self.assertEqual(p.exitcode, expected)
1169
1170#
1171#

Callers

nothing calls this directly

Calls 13

join_processFunction · 0.85
strFunction · 0.85
skipTestMethod · 0.80
addCleanupMethod · 0.80
openFunction · 0.50
formatMethod · 0.45
ProcessMethod · 0.45
startMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45
rstripMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected