@@ -664,41 +664,39 @@ def test_environ(self):
664664 self .assertEqual (type (v ), item_type )
665665
666666 def test_getcwd_long_pathnames (self ):
667- if hasattr (posix , 'getcwd' ):
668- dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
669- curdir = os .getcwd ()
670- base_path = os .path .abspath (support .TESTFN ) + '.getcwd'
667+ dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
668+ curdir = os .getcwd ()
669+ base_path = os .path .abspath (support .TESTFN ) + '.getcwd'
671670
672- try :
673- os .mkdir (base_path )
674- os .chdir (base_path )
675- except :
676- # Just returning nothing instead of the SkipTest exception,
677- # because the test results in Error in that case.
678- # Is that ok?
679- # raise unittest.SkipTest("cannot create directory for testing")
680- return
681-
682- def _create_and_do_getcwd (dirname , current_path_length = 0 ):
683- try :
684- os .mkdir (dirname )
685- except :
686- raise unittest .SkipTest ("mkdir cannot create directory sufficiently deep for getcwd test" )
687-
688- os .chdir (dirname )
689- try :
690- os .getcwd ()
691- if current_path_length < 1027 :
692- _create_and_do_getcwd (dirname , current_path_length + len (dirname ) + 1 )
693- finally :
694- os .chdir ('..' )
695- os .rmdir (dirname )
696-
697- _create_and_do_getcwd (dirname )
671+ try :
672+ os .mkdir (base_path )
673+ os .chdir (base_path )
674+ except :
675+ # Just returning nothing instead of the SkipTest exception, because
676+ # the test results in Error in that case. Is that ok?
677+ # raise unittest.SkipTest("cannot create directory for testing")
678+ return
698679
699- finally :
700- os .chdir (curdir )
701- support .rmtree (base_path )
680+ def _create_and_do_getcwd (dirname , current_path_length = 0 ):
681+ try :
682+ os .mkdir (dirname )
683+ except :
684+ raise unittest .SkipTest ("mkdir cannot create directory sufficiently deep for getcwd test" )
685+
686+ os .chdir (dirname )
687+ try :
688+ os .getcwd ()
689+ if current_path_length < 1027 :
690+ _create_and_do_getcwd (dirname , current_path_length + len (dirname ) + 1 )
691+ finally :
692+ os .chdir ('..' )
693+ os .rmdir (dirname )
694+
695+ _create_and_do_getcwd (dirname )
696+
697+ finally :
698+ os .chdir (curdir )
699+ support .rmtree (base_path )
702700
703701 @unittest .skipUnless (hasattr (posix , 'getgrouplist' ), "test needs posix.getgrouplist()" )
704702 @unittest .skipUnless (hasattr (pwd , 'getpwuid' ), "test needs pwd.getpwuid()" )
0 commit comments