@@ -1251,6 +1251,26 @@ def test_cwd(self):
12511251 p = self .cls .cwd ()
12521252 self ._test_cwd (p )
12531253
1254+ def test_samefile (self ):
1255+ fileA_path = os .path .join (BASE , 'fileA' )
1256+ fileB_path = os .path .join (BASE , 'dirB' , 'fileB' )
1257+ p = self .cls (fileA_path )
1258+ pp = self .cls (fileA_path )
1259+ q = self .cls (fileB_path )
1260+ self .assertTrue (p .samefile (fileA_path ))
1261+ self .assertTrue (p .samefile (pp ))
1262+ self .assertFalse (p .samefile (fileB_path ))
1263+ self .assertFalse (p .samefile (q ))
1264+ # Test the non-existent file case
1265+ non_existent = os .path .join (BASE , 'foo' )
1266+ r = self .cls (non_existent )
1267+ self .assertRaises (FileNotFoundError , p .samefile , r )
1268+ self .assertRaises (FileNotFoundError , p .samefile , non_existent )
1269+ self .assertRaises (FileNotFoundError , r .samefile , p )
1270+ self .assertRaises (FileNotFoundError , r .samefile , non_existent )
1271+ self .assertRaises (FileNotFoundError , r .samefile , r )
1272+ self .assertRaises (FileNotFoundError , r .samefile , non_existent )
1273+
12541274 def test_empty_path (self ):
12551275 # The empty path points to '.'
12561276 p = self .cls ('' )
0 commit comments