(self, kwargs)
| 884 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
| 885 | @_parameterize({}, {'strict': True}, {'strict': ALL_BUT_LAST}, {'strict': ALLOW_MISSING}) |
| 886 | def test_realpath_symlink_prefix(self, kwargs): |
| 887 | ABSTFN = ntpath.abspath(os_helper.TESTFN) |
| 888 | self.addCleanup(os_helper.unlink, ABSTFN + "3") |
| 889 | self.addCleanup(os_helper.unlink, "\\\\?\\" + ABSTFN + "3.") |
| 890 | self.addCleanup(os_helper.unlink, ABSTFN + "3link") |
| 891 | self.addCleanup(os_helper.unlink, ABSTFN + "3.link") |
| 892 | |
| 893 | with open(ABSTFN + "3", "wb") as f: |
| 894 | f.write(b'0') |
| 895 | os.symlink(ABSTFN + "3", ABSTFN + "3link") |
| 896 | |
| 897 | with open("\\\\?\\" + ABSTFN + "3.", "wb") as f: |
| 898 | f.write(b'1') |
| 899 | os.symlink("\\\\?\\" + ABSTFN + "3.", ABSTFN + "3.link") |
| 900 | |
| 901 | self.assertPathEqual(ntpath.realpath(ABSTFN + "3link", **kwargs), |
| 902 | ABSTFN + "3") |
| 903 | self.assertPathEqual(ntpath.realpath(ABSTFN + "3.link", **kwargs), |
| 904 | "\\\\?\\" + ABSTFN + "3.") |
| 905 | |
| 906 | # Resolved paths should be usable to open target files |
| 907 | with open(ntpath.realpath(ABSTFN + "3link"), "rb") as f: |
| 908 | self.assertEqual(f.read(), b'0') |
| 909 | with open(ntpath.realpath(ABSTFN + "3.link"), "rb") as f: |
| 910 | self.assertEqual(f.read(), b'1') |
| 911 | |
| 912 | # When the prefix is included, it is not stripped |
| 913 | self.assertPathEqual(ntpath.realpath("\\\\?\\" + ABSTFN + "3link", **kwargs), |
| 914 | "\\\\?\\" + ABSTFN + "3") |
| 915 | self.assertPathEqual(ntpath.realpath("\\\\?\\" + ABSTFN + "3.link", **kwargs), |
| 916 | "\\\\?\\" + ABSTFN + "3.") |
| 917 | |
| 918 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
| 919 | def test_realpath_nul(self): |
nothing calls this directly
no test coverage detected