#NEWLINE# def test_already_exists_rollback_dir( self ) : #NEWLINE# #INDENT# tempdir = tempfile . mkdtemp ( ) #NEWLINE# try : #NEWLINE# #INDENT# dir_one = os . path . join ( file_two , 'dir_one' ) #NEWLINE# file_two = os . path . join ( tempdir , 'two.txt' ) #NEWLINE# open ( file_two , 'w' ) . close ( ) #NEWLINE# afc = util . AtomicFileCreator ( ) #NEWLINE# afc . create_file ( 'dir' , dir_one , None ) #NEWLINE# try : #NEWLINE# #INDENT# afc . create_file ( 'file' , file_two , 'def' ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# assert os . path . exists ( dir_one ) #NEWLINE# assert os . path . isdir ( dir_one ) #NEWLINE# afc . _rollback ( ) #NEWLINE# assert ( not os . path . exists ( dir_one ) ) #NEWLINE# assert os . path . exists ( file_two ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# assert False , 'Expected IOError not raised' #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# shutil . rmtree ( tempdir )