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

Method test_import

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

Source from the content-addressed store, hash-verified

1117 self.assertFalse(filecmp.cmp(pycs[1], pycs[2], shallow=True))
1118
1119 def test_import(self):
1120 # Test that import updates a single pyc file when pyc files already
1121 # exists and the script content changed
1122 with self.temporary_directory():
1123 script = self.make_script(self.create_code(), name="module")
1124 self.compile_dir()
1125 # All three levels have the same inode
1126 self.check_hardlinks(script)
1127
1128 pycs = get_pycs(script)
1129 inode = os.stat(pycs[0]).st_ino
1130
1131 # Change of the module content
1132 script = self.make_script("print(0)", name="module")
1133
1134 # Import the module in Python with -O (optimization level 1)
1135 script_helper.assert_python_ok(
1136 "-O", "-c", "import module", __isolated=False, PYTHONPATH=self.path
1137 )
1138
1139 # Only opt-1.pyc is changed
1140 self.assertEqual(inode, os.stat(pycs[0]).st_ino)
1141 self.assertEqual(inode, os.stat(pycs[2]).st_ino)
1142 self.assertFalse(is_hardlink(pycs[1], pycs[2]))
1143 # opt-1.pyc and opt-2.pyc have different content
1144 self.assertFalse(filecmp.cmp(pycs[1], pycs[2], shallow=True))
1145
1146
1147class HardlinkDedupTestsWithSourceEpoch(HardlinkDedupTestsBase,

Callers

nothing calls this directly

Calls 11

temporary_directoryMethod · 0.95
make_scriptMethod · 0.95
create_codeMethod · 0.95
compile_dirMethod · 0.95
check_hardlinksMethod · 0.95
get_pycsFunction · 0.85
is_hardlinkFunction · 0.85
assertFalseMethod · 0.80
statMethod · 0.45
assertEqualMethod · 0.45
cmpMethod · 0.45

Tested by

no test coverage detected