@@ -35,6 +35,10 @@ def skip_if_ABSTFN_contains_backslash(test):
3535 return [test , unittest .skip (msg )(test )][found_backslash ]
3636
3737
38+ def _parameterize (* parameters ):
39+ return support .subTests ('kwargs' , parameters )
40+
41+
3842class PosixPathTest (unittest .TestCase ):
3943
4044 def setUp (self ):
@@ -444,7 +448,7 @@ def test_normpath(self):
444448 self .assertEqual (result , expected )
445449
446450 @skip_if_ABSTFN_contains_backslash
447- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
451+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
448452 def test_realpath_curdir (self , kwargs ):
449453 self .assertEqual (realpath ('.' , ** kwargs ), os .getcwd ())
450454 self .assertEqual (realpath ('./.' , ** kwargs ), os .getcwd ())
@@ -455,7 +459,7 @@ def test_realpath_curdir(self, kwargs):
455459 self .assertEqual (realpath (b'/' .join ([b'.' ] * 100 ), ** kwargs ), os .getcwdb ())
456460
457461 @skip_if_ABSTFN_contains_backslash
458- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
462+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
459463 def test_realpath_pardir (self , kwargs ):
460464 self .assertEqual (realpath ('..' , ** kwargs ), dirname (os .getcwd ()))
461465 self .assertEqual (realpath ('../..' , ** kwargs ), dirname (dirname (os .getcwd ())))
@@ -467,7 +471,7 @@ def test_realpath_pardir(self, kwargs):
467471
468472 @os_helper .skip_unless_symlink
469473 @skip_if_ABSTFN_contains_backslash
470- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
474+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
471475 def test_realpath_basic (self , kwargs ):
472476 # Basic operation.
473477 try :
@@ -585,7 +589,7 @@ def test_realpath_invalid_paths(self):
585589
586590 @os_helper .skip_unless_symlink
587591 @skip_if_ABSTFN_contains_backslash
588- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
592+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
589593 def test_realpath_relative (self , kwargs ):
590594 try :
591595 os .symlink (posixpath .relpath (ABSTFN + "1" ), ABSTFN )
@@ -595,7 +599,7 @@ def test_realpath_relative(self, kwargs):
595599
596600 @os_helper .skip_unless_symlink
597601 @skip_if_ABSTFN_contains_backslash
598- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
602+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
599603 def test_realpath_missing_pardir (self , kwargs ):
600604 try :
601605 os .symlink (TESTFN + "1" , TESTFN )
@@ -647,7 +651,7 @@ def test_realpath_symlink_loops(self):
647651
648652 @os_helper .skip_unless_symlink
649653 @skip_if_ABSTFN_contains_backslash
650- @support . subTests ( 'kwargs' , ( {'strict' : True }, {'strict' : ALLOW_MISSING }) )
654+ @_parameterize ( {'strict' : True }, {'strict' : ALLOW_MISSING })
651655 def test_realpath_symlink_loops_strict (self , kwargs ):
652656 # Bug #43757, raise OSError if we get into an infinite symlink loop in
653657 # the strict modes.
@@ -689,7 +693,7 @@ def test_realpath_symlink_loops_strict(self, kwargs):
689693
690694 @os_helper .skip_unless_symlink
691695 @skip_if_ABSTFN_contains_backslash
692- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
696+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
693697 def test_realpath_repeated_indirect_symlinks (self , kwargs ):
694698 # Issue #6975.
695699 try :
@@ -704,7 +708,7 @@ def test_realpath_repeated_indirect_symlinks(self, kwargs):
704708
705709 @os_helper .skip_unless_symlink
706710 @skip_if_ABSTFN_contains_backslash
707- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
711+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
708712 def test_realpath_deep_recursion (self , kwargs ):
709713 depth = 10
710714 try :
@@ -724,7 +728,7 @@ def test_realpath_deep_recursion(self, kwargs):
724728
725729 @os_helper .skip_unless_symlink
726730 @skip_if_ABSTFN_contains_backslash
727- @support . subTests ( 'kwargs' , ( {}, {'strict' : ALLOW_MISSING }) )
731+ @_parameterize ( {}, {'strict' : ALLOW_MISSING })
728732 def test_realpath_resolve_parents (self , kwargs ):
729733 # We also need to resolve any symlinks in the parents of a relative
730734 # path passed to realpath. E.g.: current working directory is
@@ -745,7 +749,7 @@ def test_realpath_resolve_parents(self, kwargs):
745749
746750 @os_helper .skip_unless_symlink
747751 @skip_if_ABSTFN_contains_backslash
748- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
752+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
749753 def test_realpath_resolve_before_normalizing (self , kwargs ):
750754 # Bug #990669: Symbolic links should be resolved before we
751755 # 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):
774778
775779 @os_helper .skip_unless_symlink
776780 @skip_if_ABSTFN_contains_backslash
777- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
781+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
778782 def test_realpath_resolve_first (self , kwargs ):
779783 # Bug #1213894: The first component of the path, if not absolute,
780784 # must be resolved too.
@@ -812,7 +816,7 @@ def test_realpath_unreadable_symlink(self):
812816 @skip_if_ABSTFN_contains_backslash
813817 @unittest .skipIf (os .chmod not in os .supports_follow_symlinks , "Can't set symlink permissions" )
814818 @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 })
816820 def test_realpath_unreadable_symlink_strict (self , kwargs ):
817821 try :
818822 os .symlink (ABSTFN + "1" , ABSTFN )
@@ -1148,7 +1152,7 @@ def test_path_normpath(self):
11481152 def test_path_abspath (self ):
11491153 self .assertPathEqual (self .path .abspath )
11501154
1151- @support . subTests ( 'kwargs' , ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING }) )
1155+ @_parameterize ( {}, {'strict' : True }, {'strict' : ALLOW_MISSING })
11521156 def test_path_realpath (self , kwargs ):
11531157 self .assertPathEqual (self .path .realpath )
11541158
0 commit comments