@@ -1019,7 +1019,6 @@ def test_realpath_permission(self):
10191019    @unittest .skipUnless (HAVE_GETFINALPATHNAME , 'need _getfinalpathname' ) 
10201020    def  test_realpath_mode (self ):
10211021        realpath  =  ntpath .realpath 
1022-         ALL_BUT_LAST  =  ntpath .ALL_BUT_LAST 
10231022        ABSTFN  =  ntpath .abspath (os_helper .TESTFN )
10241023        self .addCleanup (os_helper .rmdir , ABSTFN )
10251024        self .addCleanup (os_helper .rmdir , ABSTFN  +  "/dir" )
@@ -1052,93 +1051,121 @@ def check(path, mode, expected, errno=None):
10521051
10531052        self .enterContext (os_helper .change_cwd (ABSTFN ))
10541053        check ("file" , False , "/file" )
1054+         check ("file" , ALLOW_MISSING , "/file" )
10551055        check ("file" , ALL_BUT_LAST , "/file" )
10561056        check ("file" , True , "/file" )
10571057        check ("file/" , False , "/file" )
1058+         check ("file/" , ALLOW_MISSING , "/file" )
10581059        check ("file/" , ALL_BUT_LAST , "/file" )
10591060        check ("file/" , True , "/file" )
10601061        check ("file/file2" , False , "/file/file2" )
1062+         check ("file/file2" , ALLOW_MISSING , FileNotFoundError )
10611063        check ("file/file2" , ALL_BUT_LAST , FileNotFoundError )
10621064        check ("file/file2" , True , FileNotFoundError )
10631065        check ("file/." , False , "/file" )
1066+         check ("file/." , ALLOW_MISSING , "/file" )
10641067        check ("file/." , ALL_BUT_LAST , "/file" )
10651068        check ("file/." , True , "/file" )
10661069        check ("file/../link2" , False , "/dir" )
1070+         check ("file/../link2" , ALLOW_MISSING , "/dir" )
10671071        check ("file/../link2" , ALL_BUT_LAST , "/dir" )
10681072        check ("file/../link2" , True , "/dir" )
10691073
10701074        check ("dir" , False , "/dir" )
1075+         check ("dir" , ALLOW_MISSING , "/dir" )
10711076        check ("dir" , ALL_BUT_LAST , "/dir" )
10721077        check ("dir" , True , "/dir" )
10731078        check ("dir/" , False , "/dir" )
1079+         check ("dir/" , ALLOW_MISSING , "/dir" )
10741080        check ("dir/" , ALL_BUT_LAST , "/dir" )
10751081        check ("dir/" , True , "/dir" )
10761082        check ("dir/file2" , False , "/dir/file2" )
1083+         check ("dir/file2" , ALLOW_MISSING , "/dir/file2" )
10771084        check ("dir/file2" , ALL_BUT_LAST , "/dir/file2" )
10781085        check ("dir/file2" , True , "/dir/file2" )
10791086
10801087        check ("link" , False , "/file" )
1088+         check ("link" , ALLOW_MISSING , "/file" )
10811089        check ("link" , ALL_BUT_LAST , "/file" )
10821090        check ("link" , True , "/file" )
10831091        check ("link/" , False , "/file" )
1092+         check ("link/" , ALLOW_MISSING , "/file" )
10841093        check ("link/" , ALL_BUT_LAST , "/file" )
10851094        check ("link/" , True , "/file" )
10861095        check ("link/file2" , False , "/file/file2" )
1096+         check ("link/file2" , ALLOW_MISSING , FileNotFoundError )
10871097        check ("link/file2" , ALL_BUT_LAST , FileNotFoundError )
10881098        check ("link/file2" , True , FileNotFoundError )
10891099        check ("link/." , False , "/file" )
1100+         check ("link/." , ALLOW_MISSING , "/file" )
10901101        check ("link/." , ALL_BUT_LAST , "/file" )
10911102        check ("link/." , True , "/file" )
10921103        check ("link/../link" , False , "/file" )
1104+         check ("link/../link" , ALLOW_MISSING , "/file" )
10931105        check ("link/../link" , ALL_BUT_LAST , "/file" )
10941106        check ("link/../link" , True , "/file" )
10951107
10961108        check ("link2" , False , "/dir" )
1109+         check ("link2" , ALLOW_MISSING , "/dir" )
10971110        check ("link2" , ALL_BUT_LAST , "/dir" )
10981111        check ("link2" , True , "/dir" )
10991112        check ("link2/" , False , "/dir" )
1113+         check ("link2/" , ALLOW_MISSING , "/dir" )
11001114        check ("link2/" , ALL_BUT_LAST , "/dir" )
11011115        check ("link2/" , True , "/dir" )
11021116        check ("link2/file2" , False , "/dir/file2" )
1117+         check ("link2/file2" , ALLOW_MISSING , "/dir/file2" )
11031118        check ("link2/file2" , ALL_BUT_LAST , "/dir/file2" )
11041119        check ("link2/file2" , True , "/dir/file2" )
11051120
11061121        check ("nonexistent" , False , "/nonexistent" )
1122+         check ("nonexistent" , ALLOW_MISSING , "/nonexistent" )
11071123        check ("nonexistent" , ALL_BUT_LAST , "/nonexistent" )
11081124        check ("nonexistent" , True , FileNotFoundError )
11091125        check ("nonexistent/" , False , "/nonexistent" )
1126+         check ("nonexistent/" , ALLOW_MISSING , "/nonexistent" )
11101127        check ("nonexistent/" , ALL_BUT_LAST , "/nonexistent" )
11111128        check ("nonexistent/" , True , FileNotFoundError )
11121129        check ("nonexistent/file" , False , "/nonexistent/file" )
1130+         check ("nonexistent/file" , ALLOW_MISSING , "/nonexistent/file" )
11131131        check ("nonexistent/file" , ALL_BUT_LAST , FileNotFoundError )
11141132        check ("nonexistent/file" , True , FileNotFoundError )
11151133        check ("nonexistent/../link" , False , "/file" )
1134+         check ("nonexistent/../link" , ALLOW_MISSING , "/file" )
11161135        check ("nonexistent/../link" , ALL_BUT_LAST , "/file" )
11171136        check ("nonexistent/../link" , True , "/file" )
11181137
11191138        check ("broken" , False , "/nonexistent" )
1139+         check ("broken" , ALLOW_MISSING , "/nonexistent" )
11201140        check ("broken" , ALL_BUT_LAST , "/nonexistent" )
11211141        check ("broken" , True , FileNotFoundError )
11221142        check ("broken/" , False , "/nonexistent" )
1143+         check ("broken/" , ALLOW_MISSING , "/nonexistent" )
11231144        check ("broken/" , ALL_BUT_LAST , "/nonexistent" )
11241145        check ("broken/" , True , FileNotFoundError )
11251146        check ("broken/file" , False , "/nonexistent/file" )
1147+         check ("broken/file" , ALLOW_MISSING , "/nonexistent/file" )
11261148        check ("broken/file" , ALL_BUT_LAST , FileNotFoundError )
11271149        check ("broken/file" , True , FileNotFoundError )
11281150        check ("broken/../link" , False , "/file" )
1151+         check ("broken/../link" , ALLOW_MISSING , "/file" )
11291152        check ("broken/../link" , ALL_BUT_LAST , "/file" )
11301153        check ("broken/../link" , True , "/file" )
11311154
11321155        check ("cycle" , False , "/cycle" )
1156+         check ("cycle" , ALLOW_MISSING , OSError , errno .EINVAL )
11331157        check ("cycle" , ALL_BUT_LAST , OSError , errno .EINVAL )
11341158        check ("cycle" , True , OSError , errno .EINVAL )
11351159        check ("cycle/" , False , "/cycle" )
1160+         check ("cycle/" , ALLOW_MISSING , OSError , errno .EINVAL )
11361161        check ("cycle/" , ALL_BUT_LAST , OSError , errno .EINVAL )
11371162        check ("cycle/" , True , OSError , errno .EINVAL )
11381163        check ("cycle/file" , False , "/cycle/file" )
1164+         check ("cycle/file" , ALLOW_MISSING , OSError , errno .EINVAL )
11391165        check ("cycle/file" , ALL_BUT_LAST , OSError , errno .EINVAL )
11401166        check ("cycle/file" , True , OSError , errno .EINVAL )
11411167        check ("cycle/../link" , False , "/file" )
1168+         check ("cycle/../link" , ALLOW_MISSING , "/file" )
11421169        check ("cycle/../link" , ALL_BUT_LAST , "/file" )
11431170        check ("cycle/../link" , True , "/file" )
11441171
0 commit comments