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

Method test_fromfile

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

Source from the content-addressed store, hash-verified

1145 self.assertTrue(randseed.isdigit(), randseed)
1146
1147 def test_fromfile(self):
1148 # test --fromfile
1149 tests = [self.create_test() for index in range(5)]
1150
1151 # Write the list of files using a format similar to regrtest output:
1152 # [1/2] test_1
1153 # [2/2] test_2
1154 filename = os_helper.TESTFN
1155 self.addCleanup(os_helper.unlink, filename)
1156
1157 # test format '0:00:00 [2/7] test_opcodes -- test_grammar took 0 sec'
1158 with open(filename, "w") as fp:
1159 previous = None
1160 for index, name in enumerate(tests, 1):
1161 line = ("00:00:%02i [%s/%s] %s"
1162 % (index, index, len(tests), name))
1163 if previous:
1164 line += " -- %s took 0 sec" % previous
1165 print(line, file=fp)
1166 previous = name
1167
1168 output = self.run_tests('--fromfile', filename)
1169 stats = len(tests)
1170 self.check_executed_tests(output, tests, stats=stats)
1171
1172 # test format '[2/7] test_opcodes'
1173 with open(filename, "w") as fp:
1174 for index, name in enumerate(tests, 1):
1175 print("[%s/%s] %s" % (index, len(tests), name), file=fp)
1176
1177 output = self.run_tests('--fromfile', filename)
1178 self.check_executed_tests(output, tests, stats=stats)
1179
1180 # test format 'test_opcodes'
1181 with open(filename, "w") as fp:
1182 for name in tests:
1183 print(name, file=fp)
1184
1185 output = self.run_tests('--fromfile', filename)
1186 self.check_executed_tests(output, tests, stats=stats)
1187
1188 # test format 'Lib/test/test_opcodes.py'
1189 with open(filename, "w") as fp:
1190 for name in tests:
1191 print('Lib/test/%s.py' % name, file=fp)
1192
1193 output = self.run_tests('--fromfile', filename)
1194 self.check_executed_tests(output, tests, stats=stats)
1195
1196 def test_interrupted(self):
1197 code = TEST_INTERRUPTED

Callers

nothing calls this directly

Calls 6

run_testsMethod · 0.95
enumerateFunction · 0.85
create_testMethod · 0.80
addCleanupMethod · 0.80
check_executed_testsMethod · 0.80
openFunction · 0.50

Tested by

no test coverage detected