<s> import pycurl <EOL> import unittest <EOL> import time as _time <EOL> from . import appmanager <EOL> from . import util <EOL> setup_module , teardown_module = appmanager . setup ( ( '<STR_LIT>' , <NUM_LIT> ) ) <EOL> class HeaderFunctionTest ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . curl = pycurl . Curl ( ) <EOL> self . header_lines = [ ] <EOL> def tearDown ( self ) : <EOL> self . curl . close ( ) <EOL> def header_function ( self , line ) : <EOL> self . header_lines . append ( line ) <EOL> def test_get ( self ) : <EOL> self . curl . setopt ( pycurl . URL , '<STR_LIT>' ) <EOL> sio = util . StringIO ( ) <EOL> self . curl . setopt ( pycurl . WRITEFUNCTION , sio . write ) <EOL> self . curl . setopt ( pycurl . HEADERFUNCTION , self . header_function ) <EOL> self . curl . perform ( ) <EOL> self . assertEqual ( '<STR_LIT:success>' , sio . getvalue ( ) ) <EOL> assert len ( self . header_lines ) > <NUM_LIT:0> <EOL> self . assertEqual ( "<STR_LIT>" , self . header_lines [ <NUM_LIT:0> ] ) <EOL> todays_day = _time . strftime ( '<STR_LIT>' , _time . gmtime ( ) ) <EOL> self . check ( '<STR_LIT>' % todays_day ) <EOL> self . check ( '<STR_LIT>' ) <EOL> self . check ( '<STR_LIT>' ) <EOL> self . check ( '<STR_LIT>' ) <EOL> def check ( self , wanted_text ) : <EOL> for line in self . header_lines : <EOL> if wanted_text in line : <EOL> return <EOL> assert False , "<STR_LIT>" % wanted_text </s>
