(self)
| 719 | @os_helper.skip_unless_symlink |
| 720 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
| 721 | def test_realpath_symlink_loops(self): |
| 722 | # Symlink loops in non-strict mode are non-deterministic as to which |
| 723 | # path is returned, but it will always be the fully resolved path of |
| 724 | # one member of the cycle |
| 725 | ABSTFN = ntpath.abspath(os_helper.TESTFN) |
| 726 | self.addCleanup(os_helper.unlink, ABSTFN) |
| 727 | self.addCleanup(os_helper.unlink, ABSTFN + "1") |
| 728 | self.addCleanup(os_helper.unlink, ABSTFN + "2") |
| 729 | self.addCleanup(os_helper.unlink, ABSTFN + "y") |
| 730 | self.addCleanup(os_helper.unlink, ABSTFN + "c") |
| 731 | self.addCleanup(os_helper.unlink, ABSTFN + "a") |
| 732 | |
| 733 | os.symlink(ABSTFN, ABSTFN) |
| 734 | self.assertPathEqual(ntpath.realpath(ABSTFN), ABSTFN) |
| 735 | |
| 736 | os.symlink(ABSTFN + "1", ABSTFN + "2") |
| 737 | os.symlink(ABSTFN + "2", ABSTFN + "1") |
| 738 | expected = (ABSTFN + "1", ABSTFN + "2") |
| 739 | self.assertPathIn(ntpath.realpath(ABSTFN + "1"), expected) |
| 740 | self.assertPathIn(ntpath.realpath(ABSTFN + "2"), expected) |
| 741 | |
| 742 | self.assertPathIn(ntpath.realpath(ABSTFN + "1\\x"), |
| 743 | (ntpath.join(r, "x") for r in expected)) |
| 744 | self.assertPathEqual(ntpath.realpath(ABSTFN + "1\\.."), |
| 745 | ntpath.dirname(ABSTFN)) |
| 746 | self.assertPathEqual(ntpath.realpath(ABSTFN + "1\\..\\x"), |
| 747 | ntpath.dirname(ABSTFN) + "\\x") |
| 748 | os.symlink(ABSTFN + "x", ABSTFN + "y") |
| 749 | self.assertPathEqual(ntpath.realpath(ABSTFN + "1\\..\\" |
| 750 | + ntpath.basename(ABSTFN) + "y"), |
| 751 | ABSTFN + "x") |
| 752 | self.assertPathIn(ntpath.realpath(ABSTFN + "1\\..\\" |
| 753 | + ntpath.basename(ABSTFN) + "1"), |
| 754 | expected) |
| 755 | |
| 756 | os.symlink(ntpath.basename(ABSTFN) + "a\\b", ABSTFN + "a") |
| 757 | self.assertPathEqual(ntpath.realpath(ABSTFN + "a"), ABSTFN + "a") |
| 758 | |
| 759 | os.symlink("..\\" + ntpath.basename(ntpath.dirname(ABSTFN)) |
| 760 | + "\\" + ntpath.basename(ABSTFN) + "c", ABSTFN + "c") |
| 761 | self.assertPathEqual(ntpath.realpath(ABSTFN + "c"), ABSTFN + "c") |
| 762 | |
| 763 | # Test using relative path as well. |
| 764 | self.assertPathEqual(ntpath.realpath(ntpath.basename(ABSTFN)), ABSTFN) |
| 765 | |
| 766 | @os_helper.skip_unless_symlink |
| 767 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
nothing calls this directly
no test coverage detected