@@ -340,8 +340,7 @@ def test_realpath_broken_symlinks(self):
340340 @os_helper .skip_unless_symlink
341341 @unittest .skipUnless (HAVE_GETFINALPATHNAME , 'need _getfinalpathname' )
342342 def test_realpath_symlink_loops (self ):
343- # Symlink loops are non-deterministic as to which path is returned, but
344- # it will always be the fully resolved path of one member of the cycle
343+ # Symlink loops raise OSError
345344 ABSTFN = ntpath .abspath (os_helper .TESTFN )
346345 self .addCleanup (os_helper .unlink , ABSTFN )
347346 self .addCleanup (os_helper .unlink , ABSTFN + "1" )
@@ -351,16 +350,13 @@ def test_realpath_symlink_loops(self):
351350 self .addCleanup (os_helper .unlink , ABSTFN + "a" )
352351
353352 os .symlink (ABSTFN , ABSTFN )
354- self .assertPathEqual ( ntpath .realpath ( ABSTFN ) , ABSTFN )
353+ self .assertRaises ( OSError , ntpath .realpath , ABSTFN )
355354
356355 os .symlink (ABSTFN + "1" , ABSTFN + "2" )
357356 os .symlink (ABSTFN + "2" , ABSTFN + "1" )
358- expected = (ABSTFN + "1" , ABSTFN + "2" )
359- self .assertPathIn (ntpath .realpath (ABSTFN + "1" ), expected )
360- self .assertPathIn (ntpath .realpath (ABSTFN + "2" ), expected )
361-
362- self .assertPathIn (ntpath .realpath (ABSTFN + "1\\ x" ),
363- (ntpath .join (r , "x" ) for r in expected ))
357+ self .assertRaises (OSError , ntpath .realpath , ABSTFN + "1" )
358+ self .assertRaises (OSError , ntpath .realpath , ABSTFN + "2" )
359+ self .assertRaises (OSError , ntpath .realpath , ABSTFN + "1\\ x" )
364360 self .assertPathEqual (ntpath .realpath (ABSTFN + "1\\ .." ),
365361 ntpath .dirname (ABSTFN ))
366362 self .assertPathEqual (ntpath .realpath (ABSTFN + "1\\ ..\\ x" ),
@@ -369,9 +365,8 @@ def test_realpath_symlink_loops(self):
369365 self .assertPathEqual (ntpath .realpath (ABSTFN + "1\\ ..\\ "
370366 + ntpath .basename (ABSTFN ) + "y" ),
371367 ABSTFN + "x" )
372- self .assertPathIn (ntpath .realpath (ABSTFN + "1\\ ..\\ "
373- + ntpath .basename (ABSTFN ) + "1" ),
374- expected )
368+ self .assertRaises (OSError , ntpath .realpath ,
369+ ABSTFN + "1\\ ..\\ " + ntpath .basename (ABSTFN ) + "1" )
375370
376371 os .symlink (ntpath .basename (ABSTFN ) + "a\\ b" , ABSTFN + "a" )
377372 self .assertPathEqual (ntpath .realpath (ABSTFN + "a" ), ABSTFN + "a" )
0 commit comments