<s> import unittest <EOL> from test import test_support <EOL> import posixpath , os <EOL> from posixpath import realpath , abspath , join , dirname , basename <EOL> ABSTFN = abspath ( test_support . TESTFN ) <EOL> class PosixPathTest ( unittest . TestCase ) : <EOL> def assertIs ( self , a , b ) : <EOL> self . assert_ ( a is b ) <EOL> def test_normcase ( self ) : <EOL> p = "<STR_LIT>" <EOL> p = posixpath . normcase ( p ) <EOL> self . assertEqual ( p , posixpath . normcase ( p ) ) <EOL> self . assertRaises ( TypeError , posixpath . normcase ) <EOL> def test_join ( self ) : <EOL> self . assertEqual ( posixpath . join ( "<STR_LIT>" , "<STR_LIT:bar>" , "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . join ( "<STR_LIT>" , "<STR_LIT:bar>" , "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . join ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertRaises ( TypeError , posixpath . join ) <EOL> def test_splitdrive ( self ) : <EOL> self . assertEqual ( posixpath . splitdrive ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . splitdrive ) <EOL> def test_split ( self ) : <EOL> self . assertEqual ( posixpath . split ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:bar>" ) ) <EOL> self . assertEqual ( posixpath . split ( "<STR_LIT:/>" ) , ( "<STR_LIT:/>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . split ( "<STR_LIT:foo>" ) , ( "<STR_LIT>" , "<STR_LIT:foo>" ) ) <EOL> self . assertEqual ( posixpath . split ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:foo>" ) ) <EOL> self . assertEqual ( posixpath . split ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:bar>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . split ) <EOL> def test_splitext ( self ) : <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT:foo>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( posixpath . splitext ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . splitext ) <EOL> def test_isabs ( self ) : <EOL> self . assertIs ( posixpath . isabs ( "<STR_LIT>" ) , False ) <EOL> self . assertIs ( posixpath . isabs ( "<STR_LIT:/>" ) , True ) <EOL> self . assertIs ( posixpath . isabs ( "<STR_LIT>" ) , True ) <EOL> self . assertIs ( posixpath . isabs ( "<STR_LIT>" ) , True ) <EOL> self . assertIs ( posixpath . isabs ( "<STR_LIT>" ) , False ) <EOL> self . assertRaises ( TypeError , posixpath . isabs ) <EOL> def test_splitdrive ( self ) : <EOL> self . assertEqual ( posixpath . splitdrive ( "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . splitdrive ) <EOL> def test_basename ( self ) : <EOL> self . assertEqual ( posixpath . basename ( "<STR_LIT>" ) , "<STR_LIT:bar>" ) <EOL> self . assertEqual ( posixpath . basename ( "<STR_LIT:/>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . basename ( "<STR_LIT:foo>" ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( posixpath . basename ( "<STR_LIT>" ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( posixpath . basename ( "<STR_LIT>" ) , "<STR_LIT:bar>" ) <EOL> self . assertRaises ( TypeError , posixpath . basename ) <EOL> def test_dirname ( self ) : <EOL> self . assertEqual ( posixpath . dirname ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . dirname ( "<STR_LIT:/>" ) , "<STR_LIT:/>" ) <EOL> self . assertEqual ( posixpath . dirname ( "<STR_LIT:foo>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . dirname ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . dirname ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertRaises ( TypeError , posixpath . dirname ) <EOL> def test_commonprefix ( self ) : <EOL> self . assertEqual ( <EOL> posixpath . commonprefix ( [ ] ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> posixpath . commonprefix ( [ "<STR_LIT>" , "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> posixpath . commonprefix ( [ "<STR_LIT>" , "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( <EOL> posixpath . commonprefix ( [ "<STR_LIT>" , "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> def test_getsize ( self ) : <EOL> f = open ( test_support . TESTFN , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertEqual ( posixpath . getsize ( test_support . TESTFN ) , <NUM_LIT:3> ) <EOL> finally : <EOL> if not f . closed : <EOL> f . close ( ) <EOL> os . remove ( test_support . TESTFN ) <EOL> def test_time ( self ) : <EOL> f = open ( test_support . TESTFN , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> f = open ( test_support . TESTFN , "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT:bar>" ) <EOL> f . close ( ) <EOL> f = open ( test_support . TESTFN , "<STR_LIT:rb>" ) <EOL> d = f . read ( ) <EOL> f . close ( ) <EOL> self . assertEqual ( d , "<STR_LIT>" ) <EOL> self . assert_ ( <EOL> posixpath . getctime ( test_support . TESTFN ) <= <EOL> posixpath . getmtime ( test_support . TESTFN ) <EOL> ) <EOL> finally : <EOL> if not f . closed : <EOL> f . close ( ) <EOL> os . remove ( test_support . TESTFN ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_islink ( self ) : <EOL> self . assertIs ( posixpath . islink ( test_support . TESTFN + "<STR_LIT:1>" ) , False ) <EOL> f = open ( test_support . TESTFN + "<STR_LIT:1>" , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( posixpath . islink ( test_support . TESTFN + "<STR_LIT:1>" ) , False ) <EOL> if hasattr ( os , "<STR_LIT>" ) : <EOL> os . symlink ( test_support . TESTFN + "<STR_LIT:1>" , test_support . TESTFN + "<STR_LIT:2>" ) <EOL> self . assertIs ( posixpath . islink ( test_support . TESTFN + "<STR_LIT:2>" ) , True ) <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:1>" ) <EOL> self . assertIs ( posixpath . islink ( test_support . TESTFN + "<STR_LIT:2>" ) , True ) <EOL> self . assertIs ( posixpath . exists ( test_support . TESTFN + "<STR_LIT:2>" ) , False ) <EOL> self . assertIs ( posixpath . lexists ( test_support . TESTFN + "<STR_LIT:2>" ) , True ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:1>" ) <EOL> except os . error : <EOL> pass <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . islink ) <EOL> def test_exists ( self ) : <EOL> self . assertIs ( posixpath . exists ( test_support . TESTFN ) , False ) <EOL> f = open ( test_support . TESTFN , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( posixpath . exists ( test_support . TESTFN ) , True ) <EOL> self . assertIs ( posixpath . lexists ( test_support . TESTFN ) , True ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . exists ) <EOL> def test_isdir ( self ) : <EOL> self . assertIs ( posixpath . isdir ( test_support . TESTFN ) , False ) <EOL> f = open ( test_support . TESTFN , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( posixpath . isdir ( test_support . TESTFN ) , False ) <EOL> os . remove ( test_support . TESTFN ) <EOL> os . mkdir ( test_support . TESTFN ) <EOL> self . assertIs ( posixpath . isdir ( test_support . TESTFN ) , True ) <EOL> os . rmdir ( test_support . TESTFN ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN ) <EOL> except os . error : <EOL> pass <EOL> try : <EOL> os . rmdir ( test_support . TESTFN ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . isdir ) <EOL> def test_isfile ( self ) : <EOL> self . assertIs ( posixpath . isfile ( test_support . TESTFN ) , False ) <EOL> f = open ( test_support . TESTFN , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( posixpath . isfile ( test_support . TESTFN ) , True ) <EOL> os . remove ( test_support . TESTFN ) <EOL> os . mkdir ( test_support . TESTFN ) <EOL> self . assertIs ( posixpath . isfile ( test_support . TESTFN ) , False ) <EOL> os . rmdir ( test_support . TESTFN ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN ) <EOL> except os . error : <EOL> pass <EOL> try : <EOL> os . rmdir ( test_support . TESTFN ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . isdir ) <EOL> def test_samefile ( self ) : <EOL> f = open ( test_support . TESTFN + "<STR_LIT:1>" , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( <EOL> posixpath . samefile ( <EOL> test_support . TESTFN + "<STR_LIT:1>" , <EOL> test_support . TESTFN + "<STR_LIT:1>" <EOL> ) , <EOL> True <EOL> ) <EOL> if hasattr ( os , "<STR_LIT>" ) : <EOL> os . symlink ( <EOL> test_support . TESTFN + "<STR_LIT:1>" , <EOL> test_support . TESTFN + "<STR_LIT:2>" <EOL> ) <EOL> self . assertIs ( <EOL> posixpath . samefile ( <EOL> test_support . TESTFN + "<STR_LIT:1>" , <EOL> test_support . TESTFN + "<STR_LIT:2>" <EOL> ) , <EOL> True <EOL> ) <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> f = open ( test_support . TESTFN + "<STR_LIT:2>" , "<STR_LIT:wb>" ) <EOL> f . write ( "<STR_LIT:bar>" ) <EOL> f . close ( ) <EOL> self . assertIs ( <EOL> posixpath . samefile ( <EOL> test_support . TESTFN + "<STR_LIT:1>" , <EOL> test_support . TESTFN + "<STR_LIT:2>" <EOL> ) , <EOL> False <EOL> ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:1>" ) <EOL> except os . error : <EOL> pass <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . samefile ) <EOL> if os . name != '<STR_LIT>' : <EOL> def test_samestat ( self ) : <EOL> f = open ( test_support . TESTFN + "<STR_LIT:1>" , "<STR_LIT:wb>" ) <EOL> try : <EOL> f . write ( "<STR_LIT:foo>" ) <EOL> f . close ( ) <EOL> self . assertIs ( <EOL> posixpath . samestat ( <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:1>" ) , <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:1>" ) <EOL> ) , <EOL> True <EOL> ) <EOL> if hasattr ( os , "<STR_LIT>" ) : <EOL> if hasattr ( os , "<STR_LIT>" ) : <EOL> os . symlink ( test_support . TESTFN + "<STR_LIT:1>" , test_support . TESTFN + "<STR_LIT:2>" ) <EOL> self . assertIs ( <EOL> posixpath . samestat ( <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:1>" ) , <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> ) , <EOL> True <EOL> ) <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> f = open ( test_support . TESTFN + "<STR_LIT:2>" , "<STR_LIT:wb>" ) <EOL> f . write ( "<STR_LIT:bar>" ) <EOL> f . close ( ) <EOL> self . assertIs ( <EOL> posixpath . samestat ( <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:1>" ) , <EOL> os . stat ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> ) , <EOL> False <EOL> ) <EOL> finally : <EOL> if not f . close ( ) : <EOL> f . close ( ) <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:1>" ) <EOL> except os . error : <EOL> pass <EOL> try : <EOL> os . remove ( test_support . TESTFN + "<STR_LIT:2>" ) <EOL> except os . error : <EOL> pass <EOL> self . assertRaises ( TypeError , posixpath . samestat ) <EOL> def test_ismount ( self ) : <EOL> self . assertIs ( posixpath . ismount ( "<STR_LIT:/>" ) , True ) <EOL> self . assertRaises ( TypeError , posixpath . ismount ) <EOL> def test_expanduser ( self ) : <EOL> self . assertEqual ( posixpath . expanduser ( "<STR_LIT:foo>" ) , "<STR_LIT:foo>" ) <EOL> try : <EOL> import pwd <EOL> except ImportError : <EOL> pass <EOL> else : <EOL> self . assert_ ( isinstance ( posixpath . expanduser ( "<STR_LIT>" ) , basestring ) ) <EOL> if posixpath . expanduser ( "<STR_LIT>" ) != '<STR_LIT:/>' : <EOL> self . assertEqual ( <EOL> posixpath . expanduser ( "<STR_LIT>" ) + "<STR_LIT:/>" , <EOL> posixpath . expanduser ( "<STR_LIT>" ) <EOL> ) <EOL> self . assert_ ( isinstance ( posixpath . expanduser ( "<STR_LIT>" ) , basestring ) ) <EOL> self . assert_ ( isinstance ( posixpath . expanduser ( "<STR_LIT>" ) , basestring ) ) <EOL> self . assertRaises ( TypeError , posixpath . expanduser ) <EOL> def test_expandvars ( self ) : <EOL> oldenv = os . environ . copy ( ) <EOL> try : <EOL> os . environ . clear ( ) <EOL> os . environ [ "<STR_LIT:foo>" ] = "<STR_LIT:bar>" <EOL> os . environ [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> os . environ [ "<STR_LIT>" ] = "<STR_LIT>" <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT:foo>" ) , "<STR_LIT:foo>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . expandvars ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> finally : <EOL> os . environ . clear ( ) <EOL> os . environ . update ( oldenv ) <EOL> self . assertRaises ( TypeError , posixpath . expandvars ) <EOL> def test_normpath ( self ) : <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT:.>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT:/>" ) , "<STR_LIT:/>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT:/>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertEqual ( posixpath . normpath ( "<STR_LIT>" ) , "<STR_LIT>" ) <EOL> self . assertRaises ( TypeError , posixpath . normpath ) <EOL> def test_abspath ( self ) : <EOL> self . assert_ ( "<STR_LIT:foo>" in posixpath . abspath ( "<STR_LIT:foo>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . abspath ) <EOL> def test_realpath ( self ) : <EOL> self . assert_ ( "<STR_LIT:foo>" in realpath ( "<STR_LIT:foo>" ) ) <EOL> self . assertRaises ( TypeError , posixpath . realpath ) <EOL> if hasattr ( os , "<STR_LIT>" ) : <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_realpath_basic ( self ) : <EOL> try : <EOL> os . symlink ( ABSTFN + "<STR_LIT:1>" , ABSTFN ) <EOL> self . assertEqual ( realpath ( ABSTFN ) , ABSTFN + "<STR_LIT:1>" ) <EOL> finally : <EOL> self . safe_remove ( ABSTFN ) <EOL> def test_realpath_symlink_loops ( self ) : <EOL> try : <EOL> old_path = abspath ( '<STR_LIT:.>' ) <EOL> os . symlink ( ABSTFN , ABSTFN ) <EOL> self . assertEqual ( realpath ( ABSTFN ) , ABSTFN ) <EOL> os . symlink ( ABSTFN + "<STR_LIT:1>" , ABSTFN + "<STR_LIT:2>" ) <EOL> os . symlink ( ABSTFN + "<STR_LIT:2>" , ABSTFN + "<STR_LIT:1>" ) <EOL> self . assertEqual ( realpath ( ABSTFN + "<STR_LIT:1>" ) , ABSTFN + "<STR_LIT:1>" ) <EOL> self . assertEqual ( realpath ( ABSTFN + "<STR_LIT:2>" ) , ABSTFN + "<STR_LIT:2>" ) <EOL> os . chdir ( dirname ( ABSTFN ) ) <EOL> self . assertEqual ( realpath ( basename ( ABSTFN ) ) , ABSTFN ) <EOL> finally : <EOL> os . chdir ( old_path ) <EOL> self . safe_remove ( ABSTFN ) <EOL> self . safe_remove ( ABSTFN + "<STR_LIT:1>" ) <EOL> self . safe_remove ( ABSTFN + "<STR_LIT:2>" ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_realpath_resolve_parents ( self ) : <EOL> try : <EOL> old_path = abspath ( '<STR_LIT:.>' ) <EOL> os . mkdir ( ABSTFN ) <EOL> os . mkdir ( ABSTFN + "<STR_LIT>" ) <EOL> os . symlink ( ABSTFN + "<STR_LIT>" , ABSTFN + "<STR_LIT>" ) <EOL> os . chdir ( ABSTFN + "<STR_LIT>" ) <EOL> self . assertEqual ( realpath ( "<STR_LIT:a>" ) , ABSTFN + "<STR_LIT>" ) <EOL> finally : <EOL> os . chdir ( old_path ) <EOL> self . safe_remove ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_realpath_resolve_before_normalizing ( self ) : <EOL> try : <EOL> old_path = abspath ( '<STR_LIT:.>' ) <EOL> os . mkdir ( ABSTFN ) <EOL> os . mkdir ( ABSTFN + "<STR_LIT>" ) <EOL> os . mkdir ( ABSTFN + "<STR_LIT>" ) <EOL> os . symlink ( ABSTFN + "<STR_LIT>" , ABSTFN + "<STR_LIT>" ) <EOL> self . assertEqual ( realpath ( ABSTFN + "<STR_LIT>" ) , ABSTFN + "<STR_LIT>" ) <EOL> os . chdir ( dirname ( ABSTFN ) ) <EOL> self . assertEqual ( realpath ( basename ( ABSTFN ) + "<STR_LIT>" ) , ABSTFN + "<STR_LIT>" ) <EOL> finally : <EOL> os . chdir ( old_path ) <EOL> self . safe_remove ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN ) <EOL> @ unittest . skip ( "<STR_LIT>" ) <EOL> def test_realpath_resolve_first ( self ) : <EOL> try : <EOL> old_path = abspath ( '<STR_LIT:.>' ) <EOL> os . mkdir ( ABSTFN ) <EOL> os . mkdir ( ABSTFN + "<STR_LIT>" ) <EOL> os . symlink ( ABSTFN , ABSTFN + "<STR_LIT>" ) <EOL> os . chdir ( dirname ( ABSTFN ) ) <EOL> base = basename ( ABSTFN ) <EOL> self . assertEqual ( realpath ( base + "<STR_LIT>" ) , ABSTFN ) <EOL> self . assertEqual ( realpath ( base + "<STR_LIT>" ) , ABSTFN + "<STR_LIT>" ) <EOL> finally : <EOL> os . chdir ( old_path ) <EOL> self . safe_remove ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN + "<STR_LIT>" ) <EOL> self . safe_rmdir ( ABSTFN ) <EOL> def pass_os_error ( self , func , filename ) : <EOL> try : func ( filename ) <EOL> except OSError : pass <EOL> def safe_remove ( self , filename ) : <EOL> self . pass_os_error ( os . remove , filename ) <EOL> def safe_rmdir ( self , dirname ) : <EOL> self . pass_os_error ( os . rmdir , dirname ) <EOL> def test_main ( ) : <EOL> test_support . run_unittest ( PosixPathTest ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
