summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ntpath.py
diff options
context:
space:
mode:
authorneonene <53406459+neonene@users.noreply.github.com>2022-01-13 23:35:42 (GMT)
committerGitHub <noreply@github.com>2022-01-13 23:35:42 (GMT)
commitd4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1 (patch)
treececdf1d08cb790283d061b8263086354976c4939 /Lib/test/test_ntpath.py
parentb8ddf7e794e5316981016d6d014862e3c4ce149a (diff)
downloadcpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.zip
cpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.tar.gz
cpython-d4e64cd4b0ea431d4e371f9b0a25f6b75a069dc1.tar.bz2
bpo-46362: Ensure ntpath.abspath() uses the Windows API correctly (GH-30571)
This makes ntpath.abspath()/getpath_abspath() follow normpath(), since some WinAPIs such as PathCchSkipRoot() require backslashed paths.
Diffstat (limited to 'Lib/test/test_ntpath.py')
-rw-r--r--Lib/test/test_ntpath.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index cc29881..99a77e3 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -613,6 +613,40 @@ class TestNtpath(NtpathTestCase):
@unittest.skipUnless(nt, "abspath requires 'nt' module")
def test_abspath(self):
tester('ntpath.abspath("C:\\")', "C:\\")
+ tester('ntpath.abspath("\\\\?\\C:////spam////eggs. . .")', "\\\\?\\C:\\spam\\eggs")
+ tester('ntpath.abspath("\\\\.\\C:////spam////eggs. . .")', "\\\\.\\C:\\spam\\eggs")
+ tester('ntpath.abspath("//spam//eggs. . .")', "\\\\spam\\eggs")
+ tester('ntpath.abspath("\\\\spam\\\\eggs. . .")', "\\\\spam\\eggs")
+ tester('ntpath.abspath("C:/spam. . .")', "C:\\spam")
+ tester('ntpath.abspath("C:\\spam. . .")', "C:\\spam")
+ tester('ntpath.abspath("C:/nul")', "\\\\.\\nul")
+ tester('ntpath.abspath("C:\\nul")', "\\\\.\\nul")
+ tester('ntpath.abspath("//..")', "\\\\")
+ tester('ntpath.abspath("//../")', "\\\\..\\")
+ tester('ntpath.abspath("//../..")', "\\\\..\\")
+ tester('ntpath.abspath("//../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../..")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//../../../../")', "\\\\..\\..\\")
+ tester('ntpath.abspath("//server")', "\\\\server")
+ tester('ntpath.abspath("//server/")', "\\\\server\\")
+ tester('ntpath.abspath("//server/..")', "\\\\server\\")
+ tester('ntpath.abspath("//server/../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../..")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../..")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/../../../")', "\\\\server\\..\\")
+ tester('ntpath.abspath("//server/share")', "\\\\server\\share")
+ tester('ntpath.abspath("//server/share/")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/..")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../..")', "\\\\server\\share\\")
+ tester('ntpath.abspath("//server/share/../../")', "\\\\server\\share\\")
+ tester('ntpath.abspath("C:\\nul. . .")', "\\\\.\\nul")
+ tester('ntpath.abspath("//... . .")', "\\\\")
+ tester('ntpath.abspath("//.. . . .")', "\\\\")
+ tester('ntpath.abspath("//../... . .")', "\\\\..\\")
+ tester('ntpath.abspath("//../.. . . .")', "\\\\..\\")
with os_helper.temp_cwd(os_helper.TESTFN) as cwd_dir: # bpo-31047
tester('ntpath.abspath("")', cwd_dir)
tester('ntpath.abspath(" ")', cwd_dir + "\\ ")