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

Method test_hardlink

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

Source from the content-addressed store, hash-verified

952 self.assertRunNotOK(self.directory, "-o 1", "--hardlink-dupes")
953
954 def test_hardlink(self):
955 # 'a = 0' code produces the same bytecode for the 3 optimization
956 # levels. All three .pyc files must have the same inode (hardlinks).
957 #
958 # If deduplication is disabled, all pyc files must have different
959 # inodes.
960 for dedup in (True, False):
961 with tempfile.TemporaryDirectory() as path:
962 with self.subTest(dedup=dedup):
963 script = script_helper.make_script(path, "script", "a = 0")
964 pycs = get_pycs(script)
965
966 args = ["-q", "-o 0", "-o 1", "-o 2"]
967 if dedup:
968 args.append("--hardlink-dupes")
969 self.assertRunOK(path, *args)
970
971 self.assertEqual(is_hardlink(pycs[0], pycs[1]), dedup)
972 self.assertEqual(is_hardlink(pycs[1], pycs[2]), dedup)
973 self.assertEqual(is_hardlink(pycs[0], pycs[2]), dedup)
974
975
976class CommandLineTestsWithSourceEpoch(CommandLineTestsBase,

Callers

nothing calls this directly

Calls 7

assertRunOKMethod · 0.95
get_pycsFunction · 0.85
is_hardlinkFunction · 0.85
subTestMethod · 0.45
make_scriptMethod · 0.45
appendMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected