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

Method test_splitroot

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

Source from the content-addressed store, hash-verified

148 (b'\\\\\xff\\\xfe', b'\\\xfd'))
149
150 def test_splitroot(self):
151 tester("ntpath.splitroot('')", ('', '', ''))
152 tester("ntpath.splitroot('foo')", ('', '', 'foo'))
153 tester("ntpath.splitroot('foo\\bar')", ('', '', 'foo\\bar'))
154 tester("ntpath.splitroot('foo/bar')", ('', '', 'foo/bar'))
155 tester("ntpath.splitroot('\\')", ('', '\\', ''))
156 tester("ntpath.splitroot('/')", ('', '/', ''))
157 tester("ntpath.splitroot('\\foo\\bar')", ('', '\\', 'foo\\bar'))
158 tester("ntpath.splitroot('/foo/bar')", ('', '/', 'foo/bar'))
159 tester('ntpath.splitroot("c:foo\\bar")', ('c:', '', 'foo\\bar'))
160 tester('ntpath.splitroot("c:foo/bar")', ('c:', '', 'foo/bar'))
161 tester('ntpath.splitroot("c:\\foo\\bar")', ('c:', '\\', 'foo\\bar'))
162 tester('ntpath.splitroot("c:/foo/bar")', ('c:', '/', 'foo/bar'))
163
164 # Redundant slashes are not included in the root.
165 tester("ntpath.splitroot('c:\\\\a')", ('c:', '\\', '\\a'))
166 tester("ntpath.splitroot('c:\\\\\\a/b')", ('c:', '\\', '\\\\a/b'))
167
168 # Mixed path separators.
169 tester("ntpath.splitroot('c:/\\')", ('c:', '/', '\\'))
170 tester("ntpath.splitroot('c:\\/')", ('c:', '\\', '/'))
171 tester("ntpath.splitroot('/\\a/b\\/\\')", ('/\\a/b', '\\', '/\\'))
172 tester("ntpath.splitroot('\\/a\\b/\\/')", ('\\/a\\b', '/', '\\/'))
173
174 # UNC paths.
175 tester("ntpath.splitroot('\\\\')", ('\\\\', '', ''))
176 tester("ntpath.splitroot('//')", ('//', '', ''))
177 tester('ntpath.splitroot("\\\\conky\\mountpoint\\foo\\bar")',
178 ('\\\\conky\\mountpoint', '\\', 'foo\\bar'))
179 tester('ntpath.splitroot("//conky/mountpoint/foo/bar")',
180 ('//conky/mountpoint', '/', 'foo/bar'))
181 tester('ntpath.splitroot("\\\\\\conky\\mountpoint\\foo\\bar")',
182 ('\\\\\\conky', '\\', 'mountpoint\\foo\\bar'))
183 tester('ntpath.splitroot("///conky/mountpoint/foo/bar")',
184 ('///conky', '/', 'mountpoint/foo/bar'))
185 tester('ntpath.splitroot("\\\\conky\\\\mountpoint\\foo\\bar")',
186 ('\\\\conky\\', '\\', 'mountpoint\\foo\\bar'))
187 tester('ntpath.splitroot("//conky//mountpoint/foo/bar")',
188 ('//conky/', '/', 'mountpoint/foo/bar'))
189
190 # Issue #19911: UNC part containing U+0130
191 self.assertEqual(ntpath.splitroot('//conky/MOUNTPOİNT/foo/bar'),
192 ('//conky/MOUNTPOİNT', '/', 'foo/bar'))
193
194 # gh-81790: support device namespace, including UNC drives.
195 tester('ntpath.splitroot("//?/c:")', ("//?/c:", "", ""))
196 tester('ntpath.splitroot("//./c:")', ("//./c:", "", ""))
197 tester('ntpath.splitroot("//?/c:/")', ("//?/c:", "/", ""))
198 tester('ntpath.splitroot("//?/c:/dir")', ("//?/c:", "/", "dir"))
199 tester('ntpath.splitroot("//?/UNC")', ("//?/UNC", "", ""))
200 tester('ntpath.splitroot("//?/UNC/")', ("//?/UNC/", "", ""))
201 tester('ntpath.splitroot("//?/UNC/server/")', ("//?/UNC/server/", "", ""))
202 tester('ntpath.splitroot("//?/UNC/server/share")', ("//?/UNC/server/share", "", ""))
203 tester('ntpath.splitroot("//?/UNC/server/share/dir")', ("//?/UNC/server/share", "/", "dir"))
204 tester('ntpath.splitroot("//?/VOLUME{00000000-0000-0000-0000-000000000000}/spam")',
205 ('//?/VOLUME{00000000-0000-0000-0000-000000000000}', '/', 'spam'))
206 tester('ntpath.splitroot("//?/BootPartition/")', ("//?/BootPartition", "/", ""))
207 tester('ntpath.splitroot("//./BootPartition/")', ("//./BootPartition", "/", ""))

Callers

nothing calls this directly

Calls 2

testerFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected