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

Method test_forever

Lib/test/test_regrtest.py:1247–1279  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1245 self.check_line(output, 'Press any key to continue')
1246
1247 def test_forever(self):
1248 # test --forever
1249 code = textwrap.dedent("""
1250 import builtins
1251 import unittest
1252
1253 class ForeverTester(unittest.TestCase):
1254 def test_run(self):
1255 # Store the state in the builtins module, because the test
1256 # module is reload at each run
1257 if 'RUN' in builtins.__dict__:
1258 builtins.__dict__['RUN'] += 1
1259 if builtins.__dict__['RUN'] >= 3:
1260 self.fail("fail at the 3rd runs")
1261 else:
1262 builtins.__dict__['RUN'] = 1
1263 """)
1264 test = self.create_test('forever', code=code)
1265
1266 # --forever
1267 output = self.run_tests('--forever', test, exitcode=EXITCODE_BAD_TEST)
1268 self.check_executed_tests(output, [test]*3, failed=test,
1269 stats=TestStats(3, 1),
1270 forever=True)
1271
1272 # --forever --rerun
1273 output = self.run_tests('--forever', '--rerun', test, exitcode=0)
1274 self.check_executed_tests(output, [test]*3,
1275 rerun=Rerun(test,
1276 match='test_run',
1277 success=True),
1278 stats=TestStats(4, 1),
1279 forever=True)
1280
1281 @support.requires_jit_disabled
1282 def check_leak(self, code, what, *, run_workers=False):

Callers

nothing calls this directly

Calls 6

run_testsMethod · 0.95
TestStatsClass · 0.90
RerunClass · 0.85
create_testMethod · 0.80
check_executed_testsMethod · 0.80
dedentMethod · 0.45

Tested by

no test coverage detected