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

Method test_import_time

Lib/test/test_cmd_line.py:1196–1212  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1194 self.assertEqual(self.res2int(res), (os.cpu_count(), os.process_cpu_count()))
1195
1196 def test_import_time(self):
1197 # os is not imported at startup
1198 code = 'import os; import os'
1199
1200 for case in 'importtime', 'importtime=1', 'importtime=true':
1201 res = assert_python_ok('-X', case, '-c', code)
1202 res_err = res.err.decode('utf-8')
1203 self.assertRegex(res_err, r'import time: \s*\d+ \| \s*\d+ \| \s*os')
1204 self.assertNotRegex(res_err, r'import time: cached\s* \| cached\s* \| os')
1205
1206 res = assert_python_ok('-X', 'importtime=2', '-c', code)
1207 res_err = res.err.decode('utf-8')
1208 self.assertRegex(res_err, r'import time: \s*\d+ \| \s*\d+ \| \s*os')
1209 self.assertRegex(res_err, r'import time: cached\s* \| cached\s* \| os')
1210
1211 assert_python_failure('-X', 'importtime=-1', '-c', code)
1212 assert_python_failure('-X', 'importtime=3', '-c', code)
1213
1214 def res2int(self, res):
1215 out = res.out.strip().decode("utf-8")

Callers

nothing calls this directly

Calls 5

assert_python_okFunction · 0.90
assert_python_failureFunction · 0.90
assertRegexMethod · 0.80
assertNotRegexMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected