#NEWLINE# @ requires_os_link #NEWLINE# def test_copy_file_hard_link_failure( self ) : #NEWLINE# #INDENT# with open ( self . source , 'w' ) as f : #NEWLINE# #INDENT# f . write ( 'some content' ) #NEWLINE# #UNINDENT# st = os . stat ( self . source ) #NEWLINE# def _os_link( * args ) : #NEWLINE# #INDENT# raise OSError ( 0 , 'linking unsupported' ) #NEWLINE# #UNINDENT# old_link = os . link #NEWLINE# os . link = _os_link #NEWLINE# try : #NEWLINE# #INDENT# copy_file ( self . source , self . target , link = 'hard' ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# os . link = old_link #NEWLINE# #UNINDENT# st2 = os . stat ( _os_link . source ) #NEWLINE# st3 = os . stat ( self . target ) #NEWLINE# self . assertTrue ( os . path . samestat ( st , st2 ) , ( st , st2 ) ) #NEWLINE# self . assertFalse ( os . path . samestat ( st2 , st3 ) , ( st2 , st3 ) ) #NEWLINE# for fn in ( self . source , self . target ) : #NEWLINE# #INDENT# with open ( fn , 'r' ) as f : #NEWLINE# #INDENT# self . assertEqual ( f . read ( ) , 'some content' )