<s> import logging <EOL> import unittest <EOL> from nose . tools import assert_equals , assert_not_equal <EOL> from desktop . lib import i18n <EOL> from hadoop import pseudo_hdfs4 <EOL> from hadoop . fs . fsutils import remove_header , do_overwrite_save <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class FsUtilsTests ( unittest . TestCase ) : <EOL> requires_hadoop = True <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . cluster = pseudo_hdfs4 . shared_cluster ( ) <EOL> def setUp ( self ) : <EOL> self . cluster . fs . setuser ( '<STR_LIT:test>' ) <EOL> def tearDown ( self ) : <EOL> try : <EOL> self . cluster . fs . purge_trash ( ) <EOL> except Exception , e : <EOL> LOG . error ( '<STR_LIT>' , e ) <EOL> def test_remove_header ( self ) : <EOL> fs = self . cluster . fs <EOL> path = "<STR_LIT>" <EOL> data_header = "<STR_LIT>" <EOL> data_body = """<STR_LIT>""" <EOL> data = data_header + '<STR_LIT:\n>' + data_body <EOL> f = fs . open ( path , "<STR_LIT:w>" ) <EOL> f . write ( "<STR_LIT:hello>" ) <EOL> f . close ( ) <EOL> encoding = i18n . get_site_encoding ( ) <EOL> do_overwrite_save ( fs , path , data . encode ( encoding ) ) <EOL> assert_not_equal ( data_body , fs . open ( path ) . read ( ) ) <EOL> remove_header ( fs , path ) <EOL> assert_equals ( data_body , fs . open ( path ) . read ( ) ) </s>
