@@ -35,6 +35,10 @@ def skip_if_ABSTFN_contains_backslash(test):
35
35
return [test , unittest .skip (msg )(test )][found_backslash ]
36
36
37
37
38
+ def _parameterize (* parameters ):
39
+ return support .subTests ('kwargs' , parameters )
40
+
41
+
38
42
class PosixPathTest (unittest .TestCase ):
39
43
40
44
def setUp (self ):
@@ -444,7 +448,7 @@ def test_normpath(self):
444
448
self .assertEqual (result , expected )
445
449
446
450
@skip_if_ABSTFN_contains_backslash
447
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
451
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
448
452
def test_realpath_curdir (self , kwargs ):
449
453
self .assertEqual (realpath ('.' , ** kwargs ), os .getcwd ())
450
454
self .assertEqual (realpath ('./.' , ** kwargs ), os .getcwd ())
@@ -455,7 +459,7 @@ def test_realpath_curdir(self, kwargs):
455
459
self .assertEqual (realpath (b'/' .join ([b'.' ] * 100 ), ** kwargs ), os .getcwdb ())
456
460
457
461
@skip_if_ABSTFN_contains_backslash
458
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
462
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
459
463
def test_realpath_pardir (self , kwargs ):
460
464
self .assertEqual (realpath ('..' , ** kwargs ), dirname (os .getcwd ()))
461
465
self .assertEqual (realpath ('../..' , ** kwargs ), dirname (dirname (os .getcwd ())))
@@ -467,7 +471,7 @@ def test_realpath_pardir(self, kwargs):
467
471
468
472
@os_helper .skip_unless_symlink
469
473
@skip_if_ABSTFN_contains_backslash
470
- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
474
+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
471
475
def test_realpath_basic (self , kwargs ):
472
476
# Basic operation.
473
477
try :
@@ -585,7 +589,7 @@ def test_realpath_invalid_paths(self):
585
589
586
590
@os_helper .skip_unless_symlink
587
591
@skip_if_ABSTFN_contains_backslash
588
- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
592
+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
589
593
def test_realpath_relative (self , kwargs ):
590
594
try :
591
595
os .symlink (posixpath .relpath (ABSTFN + "1" ), ABSTFN )
@@ -595,7 +599,7 @@ def test_realpath_relative(self, kwargs):
595
599
596
600
@os_helper .skip_unless_symlink
597
601
@skip_if_ABSTFN_contains_backslash
598
- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
602
+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
599
603
def test_realpath_missing_pardir (self , kwargs ):
600
604
try :
601
605
os .symlink (TESTFN + "1" , TESTFN )
@@ -647,7 +651,7 @@ def test_realpath_symlink_loops(self):
647
651
648
652
@os_helper .skip_unless_symlink
649
653
@skip_if_ABSTFN_contains_backslash
650
- @support . subTests ( 'kwargs' , ( {'strict' : True }, {'strict' : ALLOW_MISSING }) )
654
+ @_parameterize ( {'strict' : True }, {'strict' : ALLOW_MISSING })
651
655
def test_realpath_symlink_loops_strict (self , kwargs ):
652
656
# Bug #43757, raise OSError if we get into an infinite symlink loop in
653
657
# the strict modes.
@@ -689,7 +693,7 @@ def test_realpath_symlink_loops_strict(self, kwargs):
689
693
690
694
@os_helper .skip_unless_symlink
691
695
@skip_if_ABSTFN_contains_backslash
692
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
696
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
693
697
def test_realpath_repeated_indirect_symlinks (self , kwargs ):
694
698
# Issue #6975.
695
699
try :
@@ -704,7 +708,7 @@ def test_realpath_repeated_indirect_symlinks(self, kwargs):
704
708
705
709
@os_helper .skip_unless_symlink
706
710
@skip_if_ABSTFN_contains_backslash
707
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
711
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
708
712
def test_realpath_deep_recursion (self , kwargs ):
709
713
depth = 10
710
714
try :
@@ -724,7 +728,7 @@ def test_realpath_deep_recursion(self, kwargs):
724
728
725
729
@os_helper .skip_unless_symlink
726
730
@skip_if_ABSTFN_contains_backslash
727
- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
731
+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
728
732
def test_realpath_resolve_parents (self , kwargs ):
729
733
# We also need to resolve any symlinks in the parents of a relative
730
734
# path passed to realpath. E.g.: current working directory is
@@ -745,7 +749,7 @@ def test_realpath_resolve_parents(self, kwargs):
745
749
746
750
@os_helper .skip_unless_symlink
747
751
@skip_if_ABSTFN_contains_backslash
748
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
752
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
749
753
def test_realpath_resolve_before_normalizing (self , kwargs ):
750
754
# Bug #990669: Symbolic links should be resolved before we
751
755
# normalize the path. E.g.: if we have directories 'a', 'k' and 'y'
@@ -774,7 +778,7 @@ def test_realpath_resolve_before_normalizing(self, kwargs):
774
778
775
779
@os_helper .skip_unless_symlink
776
780
@skip_if_ABSTFN_contains_backslash
777
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
781
+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
778
782
def test_realpath_resolve_first (self , kwargs ):
779
783
# Bug #1213894: The first component of the path, if not absolute,
780
784
# must be resolved too.
@@ -812,7 +816,7 @@ def test_realpath_unreadable_symlink(self):
812
816
@skip_if_ABSTFN_contains_backslash
813
817
@unittest .skipIf (os .chmod not in os .supports_follow_symlinks , "Can't set symlink permissions" )
814
818
@unittest .skipIf (sys .platform != "darwin" , "only macOS requires read permission to readlink()" )
815
- @support . subTests ( 'kwargs' , ( {'strict' : True }, {'strict' : ALLOW_MISSING }) )
819
+ @_parameterize ( {'strict' : True }, {'strict' : ALLOW_MISSING })
816
820
def test_realpath_unreadable_symlink_strict (self , kwargs ):
817
821
try :
818
822
os .symlink (ABSTFN + "1" , ABSTFN )
@@ -1148,7 +1152,7 @@ def test_path_normpath(self):
1148
1152
def test_path_abspath (self ):
1149
1153
self .assertPathEqual (self .path .abspath )
1150
1154
1151
- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
1155
+ @_parameterize ( {}, {'strict' :
47BB
True }, {'strict' : ALLOW_MISSING })
1152
1156
def test_path_realpath (self , kwargs ):
1153
1157
self .assertPathEqual (self .path .realpath )
1154
1158
0 commit comments