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

Method test_normpath

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

Source from the content-addressed store, hash-verified

410 self.assertEqual(normcase(path), path.lower())
411
412 def test_normpath(self):
413 tester("ntpath.normpath('A//////././//.//B')", r'A\B')
414 tester("ntpath.normpath('A/./B')", r'A\B')
415 tester("ntpath.normpath('A/foo/../B')", r'A\B')
416 tester("ntpath.normpath('C:A//B')", r'C:A\B')
417 tester("ntpath.normpath('D:A/./B')", r'D:A\B')
418 tester("ntpath.normpath('e:A/foo/../B')", r'e:A\B')
419
420 tester("ntpath.normpath('C:///A//B')", r'C:\A\B')
421 tester("ntpath.normpath('D:///A/./B')", r'D:\A\B')
422 tester("ntpath.normpath('e:///A/foo/../B')", r'e:\A\B')
423
424 tester("ntpath.normpath('..')", r'..')
425 tester("ntpath.normpath('.')", r'.')
426 tester("ntpath.normpath('c:.')", 'c:')
427 tester("ntpath.normpath('')", r'.')
428 tester("ntpath.normpath('/')", '\\')
429 tester("ntpath.normpath('c:/')", 'c:\\')
430 tester("ntpath.normpath('/../.././..')", '\\')
431 tester("ntpath.normpath('c:/../../..')", 'c:\\')
432 tester("ntpath.normpath('/./a/b')", r'\a\b')
433 tester("ntpath.normpath('c:/./a/b')", r'c:\a\b')
434 tester("ntpath.normpath('../.././..')", r'..\..\..')
435 tester("ntpath.normpath('K:../.././..')", r'K:..\..\..')
436 tester("ntpath.normpath('./a/b')", r'a\b')
437 tester("ntpath.normpath('c:./a/b')", r'c:a\b')
438 tester("ntpath.normpath('C:////a/b')", r'C:\a\b')
439 tester("ntpath.normpath('//machine/share//a/b')", r'\\machine\share\a\b')
440
441 tester("ntpath.normpath('\\\\.\\NUL')", r'\\.\NUL')
442 tester("ntpath.normpath('\\\\?\\D:/XY\\Z')", r'\\?\D:/XY\Z')
443 tester("ntpath.normpath('handbook/../../Tests/image.png')", r'..\Tests\image.png')
444 tester("ntpath.normpath('handbook/../../../Tests/image.png')", r'..\..\Tests\image.png')
445 tester("ntpath.normpath('handbook///../a/.././../b/c')", r'..\b\c')
446 tester("ntpath.normpath('handbook/a/../..///../../b/c')", r'..\..\b\c')
447
448 tester("ntpath.normpath('//server/share/..')" , '\\\\server\\share\\')
449 tester("ntpath.normpath('//server/share/../')" , '\\\\server\\share\\')
450 tester("ntpath.normpath('//server/share/../..')", '\\\\server\\share\\')
451 tester("ntpath.normpath('//server/share/../../')", '\\\\server\\share\\')
452
453 # gh-96290: don't normalize partial/invalid UNC drives as rooted paths.
454 tester("ntpath.normpath('\\\\foo\\\\')", '\\\\foo\\\\')
455 tester("ntpath.normpath('\\\\foo\\')", '\\\\foo\\')
456 tester("ntpath.normpath('\\\\foo')", '\\\\foo')
457 tester("ntpath.normpath('\\\\')", '\\\\')
458 tester("ntpath.normpath('//?/UNC/server/share/..')", '\\\\?\\UNC\\server\\share\\')
459
460 def test_normpath_invalid_paths(self):
461 normpath = ntpath.normpath

Callers

nothing calls this directly

Calls 1

testerFunction · 0.85

Tested by

no test coverage detected