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

Method test_realpath_symlink_prefix

Lib/test/test_ntpath.py:857–887  ·  view source on GitHub ↗
(self, kwargs)

Source from the content-addressed store, hash-verified

855 @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
856 @_parameterize({}, {'strict': True}, {'strict': ALLOW_MISSING})
857 def test_realpath_symlink_prefix(self, kwargs):
858 ABSTFN = ntpath.abspath(os_helper.TESTFN)
859 self.addCleanup(os_helper.unlink, ABSTFN + "3")
860 self.addCleanup(os_helper.unlink, "\\\\?\\" + ABSTFN + "3.")
861 self.addCleanup(os_helper.unlink, ABSTFN + "3link")
862 self.addCleanup(os_helper.unlink, ABSTFN + "3.link")
863
864 with open(ABSTFN + "3", "wb") as f:
865 f.write(b'0')
866 os.symlink(ABSTFN + "3", ABSTFN + "3link")
867
868 with open("\\\\?\\" + ABSTFN + "3.", "wb") as f:
869 f.write(b'1')
870 os.symlink("\\\\?\\" + ABSTFN + "3.", ABSTFN + "3.link")
871
872 self.assertPathEqual(ntpath.realpath(ABSTFN + "3link", **kwargs),
873 ABSTFN + "3")
874 self.assertPathEqual(ntpath.realpath(ABSTFN + "3.link", **kwargs),
875 "\\\\?\\" + ABSTFN + "3.")
876
877 # Resolved paths should be usable to open target files
878 with open(ntpath.realpath(ABSTFN + "3link"), "rb") as f:
879 self.assertEqual(f.read(), b'0')
880 with open(ntpath.realpath(ABSTFN + "3.link"), "rb") as f:
881 self.assertEqual(f.read(), b'1')
882
883 # When the prefix is included, it is not stripped
884 self.assertPathEqual(ntpath.realpath("\\\\?\\" + ABSTFN + "3link", **kwargs),
885 "\\\\?\\" + ABSTFN + "3")
886 self.assertPathEqual(ntpath.realpath("\\\\?\\" + ABSTFN + "3.link", **kwargs),
887 "\\\\?\\" + ABSTFN + "3.")
888
889 @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname')
890 def test_realpath_nul(self):

Callers

nothing calls this directly

Calls 7

addCleanupMethod · 0.80
realpathMethod · 0.80
openFunction · 0.50
writeMethod · 0.45
assertPathEqualMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected