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

Method recreation_check

Lib/test/test_compileall.py:109–123  ·  view source on GitHub ↗

Check that compileall recreates bytecode when the new metadata is used.

(self, metadata)

Source from the content-addressed store, hash-verified

107 self.assertTrue(compileall.compile_file(self.source_path))
108
109 def recreation_check(self, metadata):
110 """Check that compileall recreates bytecode when the new metadata is
111 used."""
112 if os.environ.get('SOURCE_DATE_EPOCH'):
113 raise unittest.SkipTest('SOURCE_DATE_EPOCH is set')
114 py_compile.compile(self.source_path)
115 self.assertEqual(*self.timestamp_metadata())
116 with open(self.bc_path, 'rb') as file:
117 bc = file.read()[len(metadata):]
118 with open(self.bc_path, 'wb') as file:
119 file.write(metadata)
120 file.write(bc)
121 self.assertNotEqual(*self.timestamp_metadata())
122 compileall.compile_dir(self.directory, force=False, quiet=True)
123 self.assertTrue(*self.timestamp_metadata())
124
125 def test_mtime(self):
126 # Test a change in mtime leads to a new .pyc.

Callers 2

test_mtimeMethod · 0.95
test_magic_numberMethod · 0.95

Calls 10

timestamp_metadataMethod · 0.95
assertNotEqualMethod · 0.80
compile_dirMethod · 0.80
assertTrueMethod · 0.80
openFunction · 0.50
getMethod · 0.45
compileMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected