MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_splitroot

Method test_splitroot

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

testerFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected