MCPcopy Index your code
hub / github.com/RustPython/RustPython / recreation_check

Method recreation_check

Lib/test/test_compileall.py:105–119  ·  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

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

Callers 2

test_mtimeMethod · 0.95
test_magic_numberMethod · 0.95

Calls 11

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

Tested by

no test coverage detected