#NEWLINE# def test_custom_proxysource( self ) : #NEWLINE# #INDENT# class CustomProxySource ( BaseProxySource ) : #NEWLINE# #INDENT# def load_raw_data( self ) : #NEWLINE# #INDENT# return '\n' . join ( ( PROXY1 , ( PROXY2 + ':foo:bar' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# g = build_grab ( ) #NEWLINE# g . setup ( proxy_auto_change = False ) #NEWLINE# g . proxylist . set_source ( CustomProxySource ( ) ) #NEWLINE# g . use_next_proxy ( ) #NEWLINE# g . go ( 'http://yandex.ru' ) #NEWLINE# self . assertEqual ( self . server . request [ 'headers' ] [ 'host' ] , 'yandex.ru' ) #NEWLINE# self . assertEqual ( g . doc . headers [ 'listen-port' ] , str ( TEST_SERVER_PORT ) ) #NEWLINE# g . use_next_proxy ( ) #NEWLINE# g . go ( 'http://yandex.ru' ) #NEWLINE# self . assertEqual ( self . server . request [ 'headers' ] [ 'host' ] , 'yandex.ru' ) #NEWLINE# self . assertEqual ( g . doc . headers [ 'listen-port' ] , str ( EXTRA_PORT1 ) )