(self)
| 926 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
| 927 | @unittest.skipUnless(HAVE_GETSHORTPATHNAME, 'need _getshortpathname') |
| 928 | def test_realpath_cwd(self): |
| 929 | ABSTFN = ntpath.abspath(os_helper.TESTFN) |
| 930 | |
| 931 | os_helper.unlink(ABSTFN) |
| 932 | os_helper.rmtree(ABSTFN) |
| 933 | os.mkdir(ABSTFN) |
| 934 | self.addCleanup(os_helper.rmtree, ABSTFN) |
| 935 | |
| 936 | test_dir_long = ntpath.join(ABSTFN, "MyVeryLongDirectoryName") |
| 937 | os.mkdir(test_dir_long) |
| 938 | |
| 939 | test_dir_short = _getshortpathname(test_dir_long) |
| 940 | test_file_long = ntpath.join(test_dir_long, "file.txt") |
| 941 | test_file_short = ntpath.join(test_dir_short, "file.txt") |
| 942 | |
| 943 | with open(test_file_long, "wb") as f: |
| 944 | f.write(b"content") |
| 945 | |
| 946 | self.assertPathEqual(test_file_long, ntpath.realpath(test_file_short)) |
| 947 | |
| 948 | for kwargs in {}, {'strict': True}, {'strict': ALL_BUT_LAST}, {'strict': ALLOW_MISSING}: |
| 949 | with self.subTest(**kwargs): |
| 950 | with os_helper.change_cwd(test_dir_long): |
| 951 | self.assertPathEqual( |
| 952 | test_file_long, |
| 953 | ntpath.realpath("file.txt", **kwargs)) |
| 954 | with os_helper.change_cwd(test_dir_long.lower()): |
| 955 | self.assertPathEqual( |
| 956 | test_file_long, |
| 957 | ntpath.realpath("file.txt", **kwargs)) |
| 958 | with os_helper.change_cwd(test_dir_short): |
| 959 | self.assertPathEqual( |
| 960 | test_file_long, |
| 961 | ntpath.realpath("file.txt", **kwargs)) |
| 962 | |
| 963 | @unittest.skipUnless(HAVE_GETFINALPATHNAME, 'need _getfinalpathname') |
| 964 | def test_realpath_permission(self): |
nothing calls this directly
no test coverage detected