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

Method test_recompilation

Lib/test/test_compileall.py:1096–1119  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1094 self.assertTrue(is_hardlink(pyc1, pyc2))
1095
1096 def test_recompilation(self):
1097 # Test compile_dir() when pyc files already exists and the script
1098 # content changed
1099 with self.temporary_directory():
1100 script = self.make_script("a = 0")
1101 self.compile_dir()
1102 # All three levels have the same inode
1103 self.check_hardlinks(script)
1104
1105 pycs = get_pycs(script)
1106 inode = os.stat(pycs[0]).st_ino
1107
1108 # Change of the module content
1109 script = self.make_script("print(0)")
1110
1111 # Recompilation without -o 1
1112 self.compile_dir(optimize=[0, 2], force=True)
1113
1114 # opt-1.pyc should have the same inode as before and others should not
1115 self.assertEqual(inode, os.stat(pycs[1]).st_ino)
1116 self.assertTrue(is_hardlink(pycs[0], pycs[2]))
1117 self.assertNotEqual(inode, os.stat(pycs[2]).st_ino)
1118 # opt-1.pyc and opt-2.pyc have different content
1119 self.assertFalse(filecmp.cmp(pycs[1], pycs[2], shallow=True))
1120
1121 def test_import(self):
1122 # Test that import updates a single pyc file when pyc files already

Callers

nothing calls this directly

Calls 11

temporary_directoryMethod · 0.95
make_scriptMethod · 0.95
compile_dirMethod · 0.95
check_hardlinksMethod · 0.95
get_pycsFunction · 0.85
is_hardlinkFunction · 0.85
assertTrueMethod · 0.80
assertNotEqualMethod · 0.80
assertFalseMethod · 0.80
statMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected