MCPcopy Index your code
hub / github.com/python/cpython / test_realpath_cwd

Method test_realpath_cwd

Lib/test/test_ntpath.py:928–961  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 12

_getshortpathnameFunction · 0.85
addCleanupMethod · 0.80
openFunction · 0.50
abspathMethod · 0.45
unlinkMethod · 0.45
mkdirMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45
assertPathEqualMethod · 0.45
realpathMethod · 0.45
subTestMethod · 0.45
lowerMethod · 0.45

Tested by

no test coverage detected