#NEWLINE# def test_tiny_xml( self ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# rootdir = tempfile . mkdtemp ( ) #NEWLINE# not_exist_file = os . path . join ( rootdir , 'not_exist' ) #NEWLINE# self . assertRaises ( ValueError , tidy_xml , not_exist_file ) #NEWLINE# utf8_file = os . path . join ( rootdir , 'utf8.xml' ) #NEWLINE# with open ( utf8_file , 'ab' ) as fhand : #NEWLINE# #INDENT# fhand . write ( char ( 0 ) . encode ( 'utf8)' ) ) #NEWLINE# #UNINDENT# tidy_xml ( utf8_file ) #NEWLINE# with open ( utf8_file , 'r' ) as fhand : #NEWLINE# #INDENT# contents = fhand . read ( ) #NEWLINE# #UNINDENT# self . assertEqual ( '?' , contents ) #NEWLINE# iso_file = os . path . join ( rootdir , 'iso.xml' ) #NEWLINE# with open ( iso_file , 'ab' ) as fhand : #NEWLINE# #INDENT# fhand . write ( char ( 0 ) . encode ( 'ascii' ) ) #NEWLINE# #UNINDENT# tidy_xml ( iso_file ) #NEWLINE# with open ( iso_file , 'r' ) as fhand : #NEWLINE# #INDENT# contents = fhand . read ( ) #NEWLINE# #UNINDENT# self . assertEqual ( '?' , contents ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# shutil . rmtree ( rootdir )