(self, kwargs)
| 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): |
nothing calls this directly
no test coverage detected