• Home
  • Raw
  • Download

Lines Matching refs:P

192         P = self.cls
193 p = P('a')
194 self.assertIsInstance(p, P)
195 P('a', 'b', 'c')
196 P('/a', 'b', 'c')
197 P('a/b/c')
198 P('/a/b/c')
199 P(FakePath("a/b/c"))
200 self.assertEqual(P(P('a')), P('a'))
201 self.assertEqual(P(P('a'), 'b'), P('a/b'))
202 self.assertEqual(P(P('a'), P('b')), P('a/b'))
203 self.assertEqual(P(P('a'), P('b'), P('c')), P(FakePath("a/b/c")))
211 P = self.cls
212 p = P(*(StrSubclass(x) for x in args))
213 self.assertEqual(p, P(*args))
225 P = self.cls
226 p = P('a/b')
228 self.assertEqual(pp, P('a/b/c'))
231 self.assertEqual(pp, P('a/b/c/d'))
232 pp = p.joinpath(P('c'))
233 self.assertEqual(pp, P('a/b/c'))
235 self.assertEqual(pp, P('/c'))
239 P = self.cls
240 p = P('a/b')
242 self.assertEqual(pp, P('a/b/c'))
245 self.assertEqual(pp, P('a/b/c/d'))
247 self.assertEqual(pp, P('a/b/c/d'))
249 self.assertEqual(pp, P('c/a/b/d'))
250 pp = p / P('c')
251 self.assertEqual(pp, P('a/b/c'))
253 self.assertEqual(pp, P('/c'))
268 P = self.cls
270 self.assertEqual(P(pathstr).as_posix(), pathstr)
275 P = self.cls
276 self.assertEqual(bytes(P('a/b')), b'a' + sep + b'b')
279 P = self.cls
281 P('a').as_uri()
283 P().as_uri()
302 P = self.cls
303 self.assertEqual(P('a/b'), P('a/b'))
304 self.assertEqual(P('a/b'), P('a', 'b'))
305 self.assertNotEqual(P('a/b'), P('a'))
306 self.assertNotEqual(P('a/b'), P('/a/b'))
307 self.assertNotEqual(P('a/b'), P())
308 self.assertNotEqual(P('/a/b'), P('/'))
309 self.assertNotEqual(P(), P('/'))
310 self.assertNotEqual(P(), "")
311 self.assertNotEqual(P(), {})
312 self.assertNotEqual(P(), int)
315 P = self.cls
316 self.assertRaises(ValueError, P('a').match, '')
317 self.assertRaises(ValueError, P('a').match, '.')
319 self.assertTrue(P('b.py').match('b.py'))
320 self.assertTrue(P('a/b.py').match('b.py'))
321 self.assertTrue(P('/a/b.py').match('b.py'))
322 self.assertFalse(P('a.py').match('b.py'))
323 self.assertFalse(P('b/py').match('b.py'))
324 self.assertFalse(P('/a.py').match('b.py'))
325 self.assertFalse(P('b.py/c').match('b.py'))
327 self.assertTrue(P('b.py').match('*.py'))
328 self.assertTrue(P('a/b.py').match('*.py'))
329 self.assertTrue(P('/a/b.py').match('*.py'))
330 self.assertFalse(P('b.pyc').match('*.py'))
331 self.assertFalse(P('b./py').match('*.py'))
332 self.assertFalse(P('b.py/c').match('*.py'))
334 self.assertTrue(P('ab/c.py').match('a*/*.py'))
335 self.assertTrue(P('/d/ab/c.py').match('a*/*.py'))
336 self.assertFalse(P('a.py').match('a*/*.py'))
337 self.assertFalse(P('/dab/c.py').match('a*/*.py'))
338 self.assertFalse(P('ab/c.py/d').match('a*/*.py'))
340 self.assertTrue(P('/b.py').match('/*.py'))
341 self.assertFalse(P('b.py').match('/*.py'))
342 self.assertFalse(P('a/b.py').match('/*.py'))
343 self.assertFalse(P('/a/b.py').match('/*.py'))
345 self.assertTrue(P('/a/b.py').match('/a/*.py'))
346 self.assertFalse(P('/ab.py').match('/a/*.py'))
347 self.assertFalse(P('/a/b/c.py').match('/a/*.py'))
354 P = self.cls
355 a = P('a')
356 b = P('a/b')
357 c = P('abc')
358 d = P('b')
364 P = self.cls
365 a = P('/a')
366 b = P('/a/b')
367 c = P('/abc')
368 d = P('/b')
375 P() < {}
380 P = self.cls
381 p = P('a/b')
387 p = P('/a/b')
392 P = self.cls
393 p = P('a/b')
417 P = self.cls
418 p = P('a/b/c')
419 self.assertEqual(p.parent, P('a/b'))
420 self.assertEqual(p.parent.parent, P('a'))
421 self.assertEqual(p.parent.parent.parent, P())
422 self.assertEqual(p.parent.parent.parent.parent, P())
424 p = P('/a/b/c')
425 self.assertEqual(p.parent, P('/a/b'))
426 self.assertEqual(p.parent.parent, P('/a'))
427 self.assertEqual(p.parent.parent.parent, P('/'))
428 self.assertEqual(p.parent.parent.parent.parent, P('/'))
432 P = self.cls
433 p = P('a/b/c')
436 self.assertEqual(par[0], P('a/b'))
437 self.assertEqual(par[1], P('a'))
438 self.assertEqual(par[2], P('.'))
439 self.assertEqual(list(par), [P('a/b'), P('a'), P('.')])
447 p = P('/a/b/c')
450 self.assertEqual(par[0], P('/a/b'))
451 self.assertEqual(par[1], P('/a'))
452 self.assertEqual(par[2], P('/'))
453 self.assertEqual(list(par), [P('/a/b'), P('/a'), P('/')])
458 P = self.cls
459 self.assertEqual(P('a/b').drive, '')
460 self.assertEqual(P('/a/b').drive, '')
461 self.assertEqual(P('').drive, '')
464 P = self.cls
466 self.assertEqual(P('').root, '')
467 self.assertEqual(P('a/b').root, '')
468 self.assertEqual(P('/').root, sep)
469 self.assertEqual(P('/a/b').root, sep)
472 P = self.cls
474 self.assertEqual(P('').anchor, '')
475 self.assertEqual(P('a/b').anchor, '')
476 self.assertEqual(P('/').anchor, sep)
477 self.assertEqual(P('/a/b').anchor, sep)
480 P = self.cls
481 self.assertEqual(P('').name, '')
482 self.assertEqual(P('.').name, '')
483 self.assertEqual(P('/').name, '')
484 self.assertEqual(P('a/b').name, 'b')
485 self.assertEqual(P('/a/b').name, 'b')
486 self.assertEqual(P('/a/b/.').name, 'b')
487 self.assertEqual(P('a/b.py').name, 'b.py')
488 self.assertEqual(P('/a/b.py').name, 'b.py')
491 P = self.cls
492 self.assertEqual(P('').suffix, '')
493 self.assertEqual(P('.').suffix, '')
494 self.assertEqual(P('..').suffix, '')
495 self.assertEqual(P('/').suffix, '')
496 self.assertEqual(P('a/b').suffix, '')
497 self.assertEqual(P('/a/b').suffix, '')
498 self.assertEqual(P('/a/b/.').suffix, '')
499 self.assertEqual(P('a/b.py').suffix, '.py')
500 self.assertEqual(P('/a/b.py').suffix, '.py')
501 self.assertEqual(P('a/.hgrc').suffix, '')
502 self.assertEqual(P('/a/.hgrc').suffix, '')
503 self.assertEqual(P('a/.hg.rc').suffix, '.rc')
504 self.assertEqual(P('/a/.hg.rc').suffix, '.rc')
505 self.assertEqual(P('a/b.tar.gz').suffix, '.gz')
506 self.assertEqual(P('/a/b.tar.gz').suffix, '.gz')
507 self.assertEqual(P('a/Some name. Ending with a dot.').suffix, '')
508 self.assertEqual(P('/a/Some name. Ending with a dot.').suffix, '')
511 P = self.cls
512 self.assertEqual(P('').suffixes, [])
513 self.assertEqual(P('.').suffixes, [])
514 self.assertEqual(P('/').suffixes, [])
515 self.assertEqual(P('a/b').suffixes, [])
516 self.assertEqual(P('/a/b').suffixes, [])
517 self.assertEqual(P('/a/b/.').suffixes, [])
518 self.assertEqual(P('a/b.py').suffixes, ['.py'])
519 self.assertEqual(P('/a/b.py').suffixes, ['.py'])
520 self.assertEqual(P('a/.hgrc').suffixes, [])
521 self.assertEqual(P('/a/.hgrc').suffixes, [])
522 self.assertEqual(P('a/.hg.rc').suffixes, ['.rc'])
523 self.assertEqual(P('/a/.hg.rc').suffixes, ['.rc'])
524 self.assertEqual(P('a/b.tar.gz').suffixes, ['.tar', '.gz'])
525 self.assertEqual(P('/a/b.tar.gz').suffixes, ['.tar', '.gz'])
526 self.assertEqual(P('a/Some name. Ending with a dot.').suffixes, [])
527 self.assertEqual(P('/a/Some name. Ending with a dot.').suffixes, [])
530 P = self.cls
531 self.assertEqual(P('').stem, '')
532 self.assertEqual(P('.').stem, '')
533 self.assertEqual(P('..').stem, '..')
534 self.assertEqual(P('/').stem, '')
535 self.assertEqual(P('a/b').stem, 'b')
536 self.assertEqual(P('a/b.py').stem, 'b')
537 self.assertEqual(P('a/.hgrc').stem, '.hgrc')
538 self.assertEqual(P('a/.hg.rc').stem, '.hg')
539 self.assertEqual(P('a/b.tar.gz').stem, 'b.tar')
540 self.assertEqual(P('a/Some name. Ending with a dot.').stem,
544 P = self.cls
545 self.assertEqual(P('a/b').with_name('d.xml'), P('a/d.xml'))
546 self.assertEqual(P('/a/b').with_name('d.xml'), P('/a/d.xml'))
547 self.assertEqual(P('a/b.py').with_name('d.xml'), P('a/d.xml'))
548 self.assertEqual(P('/a/b.py').with_name('d.xml'), P('/a/d.xml'))
549 self.assertEqual(P('a/Dot ending.').with_name('d.xml'), P('a/d.xml'))
550 self.assertEqual(P('/a/Dot ending.').with_name('d.xml'), P('/a/d.xml'))
551 self.assertRaises(ValueError, P('').with_name, 'd.xml')
552 self.assertRaises(ValueError, P('.').with_name, 'd.xml')
553 self.assertRaises(ValueError, P('/').with_name, 'd.xml')
554 self.assertRaises(ValueError, P('a/b').with_name, '')
555 self.assertRaises(ValueError, P('a/b').with_name, '/c')
556 self.assertRaises(ValueError, P('a/b').with_name, 'c/')
557 self.assertRaises(ValueError, P('a/b').with_name, 'c/d')
560 P = self.cls
561 self.assertEqual(P('a/b').with_suffix('.gz'), P('a/b.gz'))
562 self.assertEqual(P('/a/b').with_suffix('.gz'), P('/a/b.gz'))
563 self.assertEqual(P('a/b.py').with_suffix('.gz'), P('a/b.gz'))
564 self.assertEqual(P('/a/b.py').with_suffix('.gz'), P('/a/b.gz'))
566 self.assertEqual(P('a/b.py').with_suffix(''), P('a/b'))
567 self.assertEqual(P('/a/b').with_suffix(''), P('/a/b'))
569 self.assertRaises(ValueError, P('').with_suffix, '.gz')
570 self.assertRaises(ValueError, P('.').with_suffix, '.gz')
571 self.assertRaises(ValueError, P('/').with_suffix, '.gz')
573 self.assertRaises(ValueError, P('a/b').with_suffix, 'gz')
574 self.assertRaises(ValueError, P('a/b').with_suffix, '/')
575 self.assertRaises(ValueError, P('a/b').with_suffix, '.')
576 self.assertRaises(ValueError, P('a/b').with_suffix, '/.gz')
577 self.assertRaises(ValueError, P('a/b').with_suffix, 'c/d')
578 self.assertRaises(ValueError, P('a/b').with_suffix, '.c/.d')
579 self.assertRaises(ValueError, P('a/b').with_suffix, './.d')
580 self.assertRaises(ValueError, P('a/b').with_suffix, '.d/.')
581 self.assertRaises(ValueError, P('a/b').with_suffix,
585 P = self.cls
586 p = P('a/b')
589 self.assertEqual(p.relative_to(P()), P('a/b'))
590 self.assertEqual(p.relative_to(''), P('a/b'))
591 self.assertEqual(p.relative_to(P('a')), P('b'))
592 self.assertEqual(p.relative_to('a'), P('b'))
593 self.assertEqual(p.relative_to('a/'), P('b'))
594 self.assertEqual(p.relative_to(P('a/b')), P())
595 self.assertEqual(p.relative_to('a/b'), P())
597 self.assertEqual(p.relative_to('a', 'b'), P())
599 self.assertRaises(ValueError, p.relative_to, P('c'))
600 self.assertRaises(ValueError, p.relative_to, P('a/b/c'))
601 self.assertRaises(ValueError, p.relative_to, P('a/c'))
602 self.assertRaises(ValueError, p.relative_to, P('/a'))
603 p = P('/a/b')
604 self.assertEqual(p.relative_to(P('/')), P('a/b'))
605 self.assertEqual(p.relative_to('/'), P('a/b'))
606 self.assertEqual(p.relative_to(P('/a')), P('b'))
607 self.assertEqual(p.relative_to('/a'), P('b'))
608 self.assertEqual(p.relative_to('/a/'), P('b'))
609 self.assertEqual(p.relative_to(P('/a/b')), P())
610 self.assertEqual(p.relative_to('/a/b'), P())
612 self.assertRaises(ValueError, p.relative_to, P('/c'))
613 self.assertRaises(ValueError, p.relative_to, P('/a/b/c'))
614 self.assertRaises(ValueError, p.relative_to, P('/a/c'))
615 self.assertRaises(ValueError, p.relative_to, P())
617 self.assertRaises(ValueError, p.relative_to, P('a'))
620 P = self.cls
621 p = P('/a/b')
635 P = self.cls
636 self.assertEqual(P('/a/b').root, '/')
637 self.assertEqual(P('///a/b').root, '/')
639 self.assertEqual(P('//a/b').root, '//')
642 P = self.cls
643 self.assertNotEqual(P('a/b'), P('A/b'))
644 self.assertEqual(P('/a'), P('///a'))
645 self.assertNotEqual(P('/a'), P('//a'))
648 P = self.cls
649 self.assertEqual(P('/').as_uri(), 'file:///')
650 self.assertEqual(P('/a/b.c').as_uri(), 'file:///a/b.c')
651 self.assertEqual(P('/a/b%#c').as_uri(), 'file:///a/b%25%23c')
655 P = self.cls
660 self.assertEqual(P('/a/b\xe9').as_uri(),
664 P = self.cls
665 self.assertFalse(P('A.py').match('a.PY'))
668 P = self.cls
669 self.assertFalse(P().is_absolute())
670 self.assertFalse(P('a').is_absolute())
671 self.assertFalse(P('a/b/').is_absolute())
672 self.assertTrue(P('/').is_absolute())
673 self.assertTrue(P('/a').is_absolute())
674 self.assertTrue(P('/a/b/').is_absolute())
675 self.assertTrue(P('//a').is_absolute())
676 self.assertTrue(P('//a/b').is_absolute())
679 P = self.cls
680 self.assertIs(False, P('').is_reserved())
681 self.assertIs(False, P('/').is_reserved())
682 self.assertIs(False, P('/foo/bar').is_reserved())
683 self.assertIs(False, P('/dev/con/PRN/NUL').is_reserved())
686 P = self.cls
687 p = P('//a')
689 self.assertEqual(pp, P('//a/b'))
690 pp = P('/a').joinpath('//c')
691 self.assertEqual(pp, P('//c'))
692 pp = P('//a').joinpath('/c')
693 self.assertEqual(pp, P('/c'))
697 P = self.cls
698 p = P('//a')
700 self.assertEqual(pp, P('//a/b'))
701 pp = P('/a') / '//c'
702 self.assertEqual(pp, P('//c'))
703 pp = P('//a') / '/c'
704 self.assertEqual(pp, P('/c'))
747 P = self.cls
748 self.assertEqual(P('c:a/b'), P('c:a/b'))
749 self.assertEqual(P('c:a/b'), P('c:', 'a', 'b'))
750 self.assertNotEqual(P('c:a/b'), P('d:a/b'))
751 self.assertNotEqual(P('c:a/b'), P('c:/a/b'))
752 self.assertNotEqual(P('/a/b'), P('c:/a/b'))
754 self.assertEqual(P('a/B'), P('A/b'))
755 self.assertEqual(P('C:a/B'), P('c:A/b'))
756 self.assertEqual(P('//Some/SHARE/a/B'), P('//somE/share/A/b'))
759 P = self.cls
761 P('/a/b').as_uri()
763 P('c:a/b').as_uri()
764 self.assertEqual(P('c:/').as_uri(), 'file:///c:/')
765 self.assertEqual(P('c:/a/b.c').as_uri(), 'file:///c:/a/b.c')
766 self.assertEqual(P('c:/a/b%#c').as_uri(), 'file:///c:/a/b%25%23c')
767 self.assertEqual(P('c:/a/b\xe9').as_uri(), 'file:///c:/a/b%C3%A9')
768 self.assertEqual(P('//some/share/').as_uri(), 'file://some/share/')
769 self.assertEqual(P('//some/share/a/b.c').as_uri(),
771 self.assertEqual(P('//some/share/a/b%#c\xe9').as_uri(),
775 P = self.cls
777 self.assertTrue(P('c:/b.py').match('/*.py'))
778 self.assertTrue(P('c:/b.py').match('c:*.py'))
779 self.assertTrue(P('c:/b.py').match('c:/*.py'))
780 self.assertFalse(P('d:/b.py').match('c:/*.py')) # wrong drive
781 self.assertFalse(P('b.py').match('/*.py'))
782 self.assertFalse(P('b.py').match('c:*.py'))
783 self.assertFalse(P('b.py').match('c:/*.py'))
784 self.assertFalse(P('c:b.py').match('/*.py'))
785 self.assertFalse(P('c:b.py').match('c:/*.py'))
786 self.assertFalse(P('/b.py').match('c:*.py'))
787 self.assertFalse(P('/b.py').match('c:/*.py'))
789 self.assertTrue(P('//some/share/a.py').match('/*.py'))
790 self.assertTrue(P('//some/share/a.py').match('//some/share/*.py'))
791 self.assertFalse(P('//other/share/a.py').match('//some/share/*.py'))
792 self.assertFalse(P('//some/share/a/b.py').match('//some/share/*.py'))
794 self.assertTrue(P('B.py').match('b.PY'))
795 self.assertTrue(P('c:/a/B.Py').match('C:/A/*.pY'))
796 self.assertTrue(P('//Some/Share/B.Py').match('//somE/sharE/*.pY'))
803 P = self.cls
804 p = P('c:A/b')
805 q = P('C:a/B')
809 p = P('//some/Share/A/b')
810 q = P('//Some/SHARE/a/B')
816 P = self.cls
817 p = P('c:a/b')
820 p = P('c:/a/b')
823 p = P('//a/b/c/d')
829 P = self.cls
830 p = P('z:a/b/c')
831 self.assertEqual(p.parent, P('z:a/b'))
832 self.assertEqual(p.parent.parent, P('z:a'))
833 self.assertEqual(p.parent.parent.parent, P('z:'))
834 self.assertEqual(p.parent.parent.parent.parent, P('z:'))
835 p = P('z:/a/b/c')
836 self.assertEqual(p.parent, P('z:/a/b'))
837 self.assertEqual(p.parent.parent, P('z:/a'))
838 self.assertEqual(p.parent.parent.parent, P('z:/'))
839 self.assertEqual(p.parent.parent.parent.parent, P('z:/'))
840 p = P('//a/b/c/d')
841 self.assertEqual(p.parent, P('//a/b/c'))
842 self.assertEqual(p.parent.parent, P('//a/b'))
843 self.assertEqual(p.parent.parent.parent, P('//a/b'))
847 P = self.cls
848 p = P('z:a/b/')
851 self.assertEqual(par[0], P('z:a'))
852 self.assertEqual(par[1], P('z:'))
853 self.assertEqual(list(par), [P('z:a'), P('z:')])
856 p = P('z:/a/b/')
859 self.assertEqual(par[0], P('z:/a'))
860 self.assertEqual(par[1], P('z:/'))
861 self.assertEqual(list(par), [P('z:/a'), P('z:/')])
864 p = P('//a/b/c/d')
867 self.assertEqual(par[0], P('//a/b/c'))
868 self.assertEqual(par[1], P('//a/b'))
869 self.assertEqual(list(par), [P('//a/b/c'), P('//a/b')])
874 P = self.cls
875 self.assertEqual(P('c:').drive, 'c:')
876 self.assertEqual(P('c:a/b').drive, 'c:')
877 self.assertEqual(P('c:/').drive, 'c:')
878 self.assertEqual(P('c:/a/b/').drive, 'c:')
879 self.assertEqual(P('//a/b').drive, '\\\\a\\b')
880 self.assertEqual(P('//a/b/').drive, '\\\\a\\b')
881 self.assertEqual(P('//a/b/c/d').drive, '\\\\a\\b')
884 P = self.cls
885 self.assertEqual(P('c:').root, '')
886 self.assertEqual(P('c:a/b').root, '')
887 self.assertEqual(P('c:/').root, '\\')
888 self.assertEqual(P('c:/a/b/').root, '\\')
889 self.assertEqual(P('//a/b').root, '\\')
890 self.assertEqual(P('//a/b/').root, '\\')
891 self.assertEqual(P('//a/b/c/d').root, '\\')
894 P = self.cls
895 self.assertEqual(P('c:').anchor, 'c:')
896 self.assertEqual(P('c:a/b').anchor, 'c:')
897 self.assertEqual(P('c:/').anchor, 'c:\\')
898 self.assertEqual(P('c:/a/b/').anchor, 'c:\\')
899 self.assertEqual(P('//a/b').anchor, '\\\\a\\b\\')
900 self.assertEqual(P('//a/b/').anchor, '\\\\a\\b\\')
901 self.assertEqual(P('//a/b/c/d').anchor, '\\\\a\\b\\')
904 P = self.cls
905 self.assertEqual(P('c:').name, '')
906 self.assertEqual(P('c:/').name, '')
907 self.assertEqual(P('c:a/b').name, 'b')
908 self.assertEqual(P('c:/a/b').name, 'b')
909 self.assertEqual(P('c:a/b.py').name, 'b.py')
910 self.assertEqual(P('c:/a/b.py').name, 'b.py')
911 self.assertEqual(P('//My.py/Share.php').name, '')
912 self.assertEqual(P('//My.py/Share.php/a/b').name, 'b')
915 P = self.cls
916 self.assertEqual(P('c:').suffix, '')
917 self.assertEqual(P('c:/').suffix, '')
918 self.assertEqual(P('c:a/b').suffix, '')
919 self.assertEqual(P('c:/a/b').suffix, '')
920 self.assertEqual(P('c:a/b.py').suffix, '.py')
921 self.assertEqual(P('c:/a/b.py').suffix, '.py')
922 self.assertEqual(P('c:a/.hgrc').suffix, '')
923 self.assertEqual(P('c:/a/.hgrc').suffix, '')
924 self.assertEqual(P('c:a/.hg.rc').suffix, '.rc')
925 self.assertEqual(P('c:/a/.hg.rc').suffix, '.rc')
926 self.assertEqual(P('c:a/b.tar.gz').suffix, '.gz')
927 self.assertEqual(P('c:/a/b.tar.gz').suffix, '.gz')
928 self.assertEqual(P('c:a/Some name. Ending with a dot.').suffix, '')
929 self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffix, '')
930 self.assertEqual(P('//My.py/Share.php').suffix, '')
931 self.assertEqual(P('//My.py/Share.php/a/b').suffix, '')
934 P = self.cls
935 self.assertEqual(P('c:').suffixes, [])
936 self.assertEqual(P('c:/').suffixes, [])
937 self.assertEqual(P('c:a/b').suffixes, [])
938 self.assertEqual(P('c:/a/b').suffixes, [])
939 self.assertEqual(P('c:a/b.py').suffixes, ['.py'])
940 self.assertEqual(P('c:/a/b.py').suffixes, ['.py'])
941 self.assertEqual(P('c:a/.hgrc').suffixes, [])
942 self.assertEqual(P('c:/a/.hgrc').suffixes, [])
943 self.assertEqual(P('c:a/.hg.rc').suffixes, ['.rc'])
944 self.assertEqual(P('c:/a/.hg.rc').suffixes, ['.rc'])
945 self.assertEqual(P('c:a/b.tar.gz').suffixes, ['.tar', '.gz'])
946 self.assertEqual(P('c:/a/b.tar.gz').suffixes, ['.tar', '.gz'])
947 self.assertEqual(P('//My.py/Share.php').suffixes, [])
948 self.assertEqual(P('//My.py/Share.php/a/b').suffixes, [])
949 self.assertEqual(P('c:a/Some name. Ending with a dot.').suffixes, [])
950 self.assertEqual(P('c:/a/Some name. Ending with a dot.').suffixes, [])
953 P = self.cls
954 self.assertEqual(P('c:').stem, '')
955 self.assertEqual(P('c:.').stem, '')
956 self.assertEqual(P('c:..').stem, '..')
957 self.assertEqual(P('c:/').stem, '')
958 self.assertEqual(P('c:a/b').stem, 'b')
959 self.assertEqual(P('c:a/b.py').stem, 'b')
960 self.assertEqual(P('c:a/.hgrc').stem, '.hgrc')
961 self.assertEqual(P('c:a/.hg.rc').stem, '.hg')
962 self.assertEqual(P('c:a/b.tar.gz').stem, 'b.tar')
963 self.assertEqual(P('c:a/Some name. Ending with a dot.').stem,
967 P = self.cls
968 self.assertEqual(P('c:a/b').with_name('d.xml'), P('c:a/d.xml'))
969 self.assertEqual(P('c:/a/b').with_name('d.xml'), P('c:/a/d.xml'))
970 self.assertEqual(P('c:a/Dot ending.').with_name('d.xml'), P('c:a/d.xml'))
971 self.assertEqual(P('c:/a/Dot ending.').with_name('d.xml'), P('c:/a/d.xml'))
972 self.assertRaises(ValueError, P('c:').with_name, 'd.xml')
973 self.assertRaises(ValueError, P('c:/').with_name, 'd.xml')
974 self.assertRaises(ValueError, P('//My/Share').with_name, 'd.xml')
975 self.assertRaises(ValueError, P('c:a/b').with_name, 'd:')
976 self.assertRaises(ValueError, P('c:a/b').with_name, 'd:e')
977 self.assertRaises(ValueError, P('c:a/b').with_name, 'd:/e')
978 self.assertRaises(ValueError, P('c:a/b').with_name, '//My/Share')
981 P = self.cls
982 self.assertEqual(P('c:a/b').with_suffix('.gz'), P('c:a/b.gz'))
983 self.assertEqual(P('c:/a/b').with_suffix('.gz'), P('c:/a/b.gz'))
984 self.assertEqual(P('c:a/b.py').with_suffix('.gz'), P('c:a/b.gz'))
985 self.assertEqual(P('c:/a/b.py').with_suffix('.gz'), P('c:/a/b.gz'))
987 self.assertRaises(ValueError, P('').with_suffix, '.gz')
988 self.assertRaises(ValueError, P('.').with_suffix, '.gz')
989 self.assertRaises(ValueError, P('/').with_suffix, '.gz')
990 self.assertRaises(ValueError, P('//My/Share').with_suffix, '.gz')
992 self.assertRaises(ValueError, P('c:a/b').with_suffix, 'gz')
993 self.assertRaises(ValueError, P('c:a/b').with_suffix, '/')
994 self.assertRaises(ValueError, P('c:a/b').with_suffix, '\\')
995 self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c:')
996 self.assertRaises(ValueError, P('c:a/b').with_suffix, '/.gz')
997 self.assertRaises(ValueError, P('c:a/b').with_suffix, '\\.gz')
998 self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c:.gz')
999 self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c/d')
1000 self.assertRaises(ValueError, P('c:a/b').with_suffix, 'c\\d')
1001 self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c/d')
1002 self.assertRaises(ValueError, P('c:a/b').with_suffix, '.c\\d')
1005 P = self.cls
1006 p = P('C:Foo/Bar')
1007 self.assertEqual(p.relative_to(P('c:')), P('Foo/Bar'))
1008 self.assertEqual(p.relative_to('c:'), P('Foo/Bar'))
1009 self.assertEqual(p.relative_to(P('c:foO')), P('Bar'))
1010 self.assertEqual(p.relative_to('c:foO'), P('Bar'))
1011 self.assertEqual(p.relative_to('c:foO/'), P('Bar'))
1012 self.assertEqual(p.relative_to(P('c:foO/baR')), P())
1013 self.assertEqual(p.relative_to('c:foO/baR'), P())
1015 self.assertRaises(ValueError, p.relative_to, P())
1017 self.assertRaises(ValueError, p.relative_to, P('d:'))
1018 self.assertRaises(ValueError, p.relative_to, P('/'))
1019 self.assertRaises(ValueError, p.relative_to, P('Foo'))
1020 self.assertRaises(ValueError, p.relative_to, P('/Foo'))
1021 self.assertRaises(ValueError, p.relative_to, P('C:/Foo'))
1022 self.assertRaises(ValueError, p.relative_to, P('C:Foo/Bar/Baz'))
1023 self.assertRaises(ValueError, p.relative_to, P('C:Foo/Baz'))
1024 p = P('C:/Foo/Bar')
1025 self.assertEqual(p.relative_to(P('c:')), P('/Foo/Bar'))
1026 self.assertEqual(p.relative_to('c:'), P('/Foo/Bar'))
1027 self.assertEqual(str(p.relative_to(P('c:'))), '\\Foo\\Bar')
1029 self.assertEqual(p.relative_to(P('c:/')), P('Foo/Bar'))
1030 self.assertEqual(p.relative_to('c:/'), P('Foo/Bar'))
1031 self.assertEqual(p.relative_to(P('c:/foO')), P('Bar'))
1032 self.assertEqual(p.relative_to('c:/foO'), P('Bar'))
1033 self.assertEqual(p.relative_to('c:/foO/'), P('Bar'))
1034 self.assertEqual(p.relative_to(P('c:/foO/baR')), P())
1035 self.assertEqual(p.relative_to('c:/foO/baR'), P())
1037 self.assertRaises(ValueError, p.relative_to, P('C:/Baz'))
1038 self.assertRaises(ValueError, p.relative_to, P('C:/Foo/Bar/Baz'))
1039 self.assertRaises(ValueError, p.relative_to, P('C:/Foo/Baz'))
1040 self.assertRaises(ValueError, p.relative_to, P('C:Foo'))
1041 self.assertRaises(ValueError, p.relative_to, P('d:'))
1042 self.assertRaises(ValueError, p.relative_to, P('d:/'))
1043 self.assertRaises(ValueError, p.relative_to, P('/'))
1044 self.assertRaises(ValueError, p.relative_to, P('/Foo'))
1045 self.assertRaises(ValueError, p.relative_to, P('//C/Foo'))
1047 p = P('//Server/Share/Foo/Bar')
1048 self.assertEqual(p.relative_to(P('//sErver/sHare')), P('Foo/Bar'))
1049 self.assertEqual(p.relative_to('//sErver/sHare'), P('Foo/Bar'))
1050 self.assertEqual(p.relative_to('//sErver/sHare/'), P('Foo/Bar'))
1051 self.assertEqual(p.relative_to(P('//sErver/sHare/Foo')), P('Bar'))
1052 self.assertEqual(p.relative_to('//sErver/sHare/Foo'), P('Bar'))
1053 self.assertEqual(p.relative_to('//sErver/sHare/Foo/'), P('Bar'))
1054 self.assertEqual(p.relative_to(P('//sErver/sHare/Foo/Bar')), P())
1055 self.assertEqual(p.relative_to('//sErver/sHare/Foo/Bar'), P())
1057 self.assertRaises(ValueError, p.relative_to, P('/Server/Share/Foo'))
1058 self.assertRaises(ValueError, p.relative_to, P('c:/Server/Share/Foo'))
1059 self.assertRaises(ValueError, p.relative_to, P('//z/Share/Foo'))
1060 self.assertRaises(ValueError, p.relative_to, P('//Server/z/Foo'))
1063 P = self.cls
1065 self.assertFalse(P().is_absolute())
1066 self.assertFalse(P('a').is_absolute())
1067 self.assertFalse(P('a/b/').is_absolute())
1068 self.assertFalse(P('/').is_absolute())
1069 self.assertFalse(P('/a').is_absolute())
1070 self.assertFalse(P('/a/b/').is_absolute())
1071 self.assertFalse(P('c:').is_absolute())
1072 self.assertFalse(P('c:a').is_absolute())
1073 self.assertFalse(P('c:a/b/').is_absolute())
1074 self.assertTrue(P('c:/').is_absolute())
1075 self.assertTrue(P('c:/a').is_absolute())
1076 self.assertTrue(P('c:/a/b/').is_absolute())
1078 self.assertTrue(P('//a/b').is_absolute())
1079 self.assertTrue(P('//a/b/').is_absolute())
1080 self.assertTrue(P('//a/b/c').is_absolute())
1081 self.assertTrue(P('//a/b/c/d').is_absolute())
1084 P = self.cls
1085 p = P('C:/a/b')
1087 self.assertEqual(pp, P('C:/a/b/x/y'))
1089 self.assertEqual(pp, P('C:/x/y'))
1093 self.assertEqual(pp, P('D:x/y'))
1095 self.assertEqual(pp, P('D:/x/y'))
1097 self.assertEqual(pp, P('//host/share/x/y'))
1101 self.assertEqual(pp, P('C:/a/b/x/y'))
1103 self.assertEqual(pp, P('C:/x/y'))
1107 P = self.cls
1108 p = P('C:/a/b')
1109 self.assertEqual(p / 'x/y', P('C:/a/b/x/y'))
1110 self.assertEqual(p / 'x' / 'y', P('C:/a/b/x/y'))
1111 self.assertEqual(p / '/x/y', P('C:/x/y'))
1112 self.assertEqual(p / '/x' / 'y', P('C:/x/y'))
1115 self.assertEqual(p / 'D:x/y', P('D:x/y'))
1116 self.assertEqual(p / 'D:' / 'x/y', P('D:x/y'))
1117 self.assertEqual(p / 'D:/x/y', P('D:/x/y'))
1118 self.assertEqual(p / 'D:' / '/x/y', P('D:/x/y'))
1119 self.assertEqual(p / '//host/share/x/y', P('//host/share/x/y'))
1122 self.assertEqual(p / 'c:x/y', P('C:/a/b/x/y'))
1123 self.assertEqual(p / 'c:/x/y', P('C:/x/y'))
1126 P = self.cls
1127 self.assertIs(False, P('').is_reserved())
1128 self.assertIs(False, P('/').is_reserved())
1129 self.assertIs(False, P('/foo/bar').is_reserved())
1130 self.assertIs(True, P('con').is_reserved())
1131 self.assertIs(True, P('NUL').is_reserved())
1132 self.assertIs(True, P('NUL.txt').is_reserved())
1133 self.assertIs(True, P('com1').is_reserved())
1134 self.assertIs(True, P('com9.bar').is_reserved())
1135 self.assertIs(False, P('bar.com9').is_reserved())
1136 self.assertIs(True, P('lpt1').is_reserved())
1137 self.assertIs(True, P('lpt9.bar').is_reserved())
1138 self.assertIs(False, P('bar.lpt9').is_reserved())
1140 self.assertIs(False, P('c:/NUL/con/baz').is_reserved())
1142 self.assertIs(False, P('//my/share/nul/con/aux').is_reserved())
1193 P = self.cls
1195 P('c:/').owner()
1198 P = self.cls
1200 P('c:/').group()
1319 P = self.cls
1320 p = P('~')
1321 self.assertEqual(p.expanduser(), P(os.path.expanduser('~')))
1322 p = P('foo')
1324 p = P('/~')
1326 p = P('../~')
1328 p = P(P('').absolute().anchor) / '~'
1332 P = self.cls
1333 p = P(BASE)
1344 self.assertIs(False, P('/xyzzy').exists())
1376 P = self.cls
1377 p = P(BASE)
1383 self.assertEqual(paths, { P(BASE, q) for q in expected })
1388 P = self.cls
1389 p = P(BASE, 'linkB')
1391 expected = { P(BASE, 'linkB', q) for q in ['fileB', 'linkD'] }
1406 self.assertEqual(set(glob), { P(BASE, q) for q in expected })
1407 P = self.cls
1408 p = P(BASE)
1430 self.assertEqual(set(glob), { P(BASE, q) for q in expected })
1431 P = self.cls
1432 p = P(BASE)
1445 p = P(BASE, "dirC")
1452 P = self.cls
1453 p = P(BASE)
1468 P = self.cls
1469 p = P(BASE)
1470 self.assertEqual(set(p.glob("..")), { P(BASE, "..") })
1471 self.assertEqual(set(p.glob("dirA/../file*")), { P(BASE, "dirA/../fileA") })
1484 P = self.cls
1485 p = P(BASE, 'foo')
1492 p = P(BASE, 'foo', 'in', 'spam')
1495 p = P(BASE, '..', 'foo', 'in', 'spam')
1499 p = P(BASE, 'dirB', 'fileB')
1501 p = P(BASE, 'linkA')
1502 self._check_resolve_relative(p, P(BASE, 'fileA'))
1503 p = P(BASE, 'dirA', 'linkC', 'fileB')
1504 self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB'))
1505 p = P(BASE, 'dirB', 'linkD', 'fileB')
1506 self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB'))
1508 p = P(BASE, 'dirA', 'linkC', 'fileB', 'foo', 'in', 'spam')
1509 self._check_resolve_relative(p, P(BASE, 'dirB', 'fileB', 'foo', 'in',
1511 p = P(BASE, 'dirA', 'linkC', '..', 'foo', 'in', 'spam')
1515 self._check_resolve_relative(p, P(BASE, 'dirA', 'foo', 'in',
1520 self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False)
1526 p = P(BASE, 'dirA', 'linkX', 'linkY', 'fileB')
1527 self._check_resolve_absolute(p, P(BASE, 'dirB', 'fileB'))
1529 p = P(BASE, 'dirA', 'linkX', 'linkY', 'foo', 'in', 'spam')
1530 self._check_resolve_relative(p, P(BASE, 'dirB', 'foo', 'in', 'spam'),
1532 p = P(BASE, 'dirA', 'linkX', 'linkY', '..', 'foo', 'in', 'spam')
1536 self._check_resolve_relative(p, P(d, 'foo', 'in', 'spam'), False)
1540 self._check_resolve_relative(p, P(BASE, 'foo', 'in', 'spam'), False)
1642 P = self.cls(BASE)
1643 p = P / 'fileA'
1646 q = P / 'dirA' / 'fileAA'
1657 P = self.cls(BASE)
1658 p = P / 'fileA'
1661 q = P / 'dirA' / 'fileAA'
1672 P = self.cls(BASE)
1673 p = P / 'newfileA'
1689 p = P / 'newfileB'
1696 P = self.cls(BASE)
1697 p = P / 'fileA'
1703 P = self.cls(BASE)
1704 p = P / 'newdirA'
1838 P = self.cls(BASE)
1839 target = P / 'fileA'
1841 link = P / 'dirA' / 'linkAA'
1846 link = P / 'dirA' / 'linkAAA'
1852 target = P / 'dirB'
1853 link = P / 'dirA' / 'linkAAAA'
1861 P = self.cls(BASE)
1862 self.assertTrue((P / 'dirA').is_dir())
1863 self.assertFalse((P / 'fileA').is_dir())
1864 self.assertFalse((P / 'non-existing').is_dir())
1865 self.assertFalse((P / 'fileA' / 'bah').is_dir())
1867 self.assertFalse((P / 'linkA').is_dir())
1868 self.assertTrue((P / 'linkB').is_dir())
1869 self.assertFalse((P/ 'brokenLink').is_dir())
1872 P = self.cls(BASE)
1873 self.assertTrue((P / 'fileA').is_file())
1874 self.assertFalse((P / 'dirA').is_file())
1875 self.assertFalse((P / 'non-existing').is_file())
1876 self.assertFalse((P / 'fileA' / 'bah').is_file())
1878 self.assertTrue((P / 'linkA').is_file())
1879 self.assertFalse((P / 'linkB').is_file())
1880 self.assertFalse((P/ 'brokenLink').is_file())
1884 P = self.cls(BASE)
1886 self.assertFalse((P / 'fileA').is_mount())
1887 self.assertFalse((P / 'dirA').is_mount())
1888 self.assertFalse((P / 'non-existing').is_mount())
1889 self.assertFalse((P / 'fileA' / 'bah').is_mount())
1892 self.assertFalse((P / 'linkA').is_mount())
1895 P = self.cls(BASE)
1896 self.assertFalse((P / 'fileA').is_symlink())
1897 self.assertFalse((P / 'dirA').is_symlink())
1898 self.assertFalse((P / 'non-existing').is_symlink())
1899 self.assertFalse((P / 'fileA' / 'bah').is_symlink())
1901 self.assertTrue((P / 'linkA').is_symlink())
1902 self.assertTrue((P / 'linkB').is_symlink())
1903 self.assertTrue((P/ 'brokenLink').is_symlink())
1906 P = self.cls(BASE)
1907 self.assertFalse((P / 'fileA').is_fifo())
1908 self.assertFalse((P / 'dirA').is_fifo())
1909 self.assertFalse((P / 'non-existing').is_fifo())
1910 self.assertFalse((P / 'fileA' / 'bah').is_fifo())
1914 P = self.cls(BASE, 'myfifo')
1916 os.mkfifo(str(P))
1919 self.assertTrue(P.is_fifo())
1920 self.assertFalse(P.is_socket())
1921 self.assertFalse(P.is_file())
1924 P = self.cls(BASE)
1925 self.assertFalse((P / 'fileA').is_socket())
1926 self.assertFalse((P / 'dirA').is_socket())
1927 self.assertFalse((P / 'non-existing').is_socket())
1928 self.assertFalse((P / 'fileA' / 'bah').is_socket())
1932 P = self.cls(BASE, 'mysock')
1936 sock.bind(str(P))
1941 self.assertTrue(P.is_socket())
1942 self.assertFalse(P.is_fifo())
1943 self.assertFalse(P.is_file())
1946 P = self.cls(BASE)
1947 self.assertFalse((P / 'fileA').is_block_device())
1948 self.assertFalse((P / 'dirA').is_block_device())
1949 self.assertFalse((P / 'non-existing').is_block_device())
1950 self.assertFalse((P / 'fileA' / 'bah').is_block_device())
1953 P = self.cls(BASE)
1954 self.assertFalse((P / 'fileA').is_char_device())
1955 self.assertFalse((P / 'dirA').is_char_device())
1956 self.assertFalse((P / 'non-existing').is_char_device())
1957 self.assertFalse((P / 'fileA' / 'bah').is_char_device())
1961 P = self.cls('/dev/null')
1962 if not P.exists():
1964 self.assertTrue(P.is_char_device())
1965 self.assertFalse(P.is_block_device())
1966 self.assertFalse(P.is_file())
1976 P = self.cls
1977 p = P('/usr/bin/foo')
1978 q = P('/usr/local/bin')
1986 P = self.cls(BASE)
1993 p = (P / 'link0').resolve()
1994 self.assertEqual(p, P)
1996 p = (P / 'link1').resolve()
1997 self.assertEqual(p, P)
1999 p = (P / 'link2').resolve()
2000 self.assertEqual(p, P)
2002 p = (P / 'link3').resolve()
2003 self.assertEqual(p, P)
2011 self.assertEqual(p, P)
2014 self.assertEqual(p, P)
2017 self.assertEqual(p, P)
2020 self.assertEqual(p, P)
2118 P = self.cls
2119 p = P(BASE)
2126 P = self.cls
2127 p = P(BASE, "dirC")
2136 P = self.cls
2152 p1 = P('~/Documents')
2153 p2 = P('~' + username + '/Documents')
2154 p3 = P('~' + othername + '/Documents')
2155 p4 = P('../~' + username + '/Documents')
2156 p5 = P('/~' + username + '/Documents')
2157 p6 = P('')
2158 p7 = P('~fakeuser/Documents')
2163 self.assertEqual(p1.expanduser(), P(userhome) / 'Documents')
2164 self.assertEqual(p2.expanduser(), P(userhome) / 'Documents')
2165 self.assertEqual(p3.expanduser(), P(otherhome) / 'Documents')
2172 self.assertEqual(p1.expanduser(), P('/tmp/Documents'))
2173 self.assertEqual(p2.expanduser(), P(userhome) / 'Documents')
2174 self.assertEqual(p3.expanduser(), P(otherhome) / 'Documents')
2209 P = self.cls
2210 p = P(BASE)
2211 self.assertEqual(set(p.glob("FILEa")), { P(BASE, "fileA") })
2214 P = self.cls
2215 p = P(BASE, "dirC")
2216 self.assertEqual(set(p.rglob("FILEd")), { P(BASE, "dirC/dirD/fileD") })
2219 P = self.cls
2228 p1 = P('~/My Documents')
2229 p2 = P('~alice/My Documents')
2230 p3 = P('~bob/My Documents')
2231 p4 = P('/~/My Documents')
2232 p5 = P('d:~/My Documents')
2233 p6 = P('')
2244 P('C:/Users/alice/My Documents'))
2248 P('C:/Users/alice/My Documents'))
2250 P('C:/Users/bob/My Documents'))