<s> import py . test <EOL> from wsgi_intercept import httplib2_intercept , WSGIAppError <EOL> from test import wsgi_app <EOL> from test . install import installer_class <EOL> import httplib2 <EOL> from socket import gaierror <EOL> HOST = '<STR_LIT>' <EOL> InstalledApp = installer_class ( httplib2_intercept ) <EOL> def test_http ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert content == b'<STR_LIT>' <EOL> assert app . success ( ) <EOL> def test_http_default_port ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert content == b'<STR_LIT>' <EOL> assert app . success ( ) <EOL> def test_http_other_port ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert content == b'<STR_LIT>' <EOL> assert app . success ( ) <EOL> environ = app . get_internals ( ) <EOL> assert environ [ '<STR_LIT>' ] == '<STR_LIT:http>' <EOL> def test_bogus_domain ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) : <EOL> py . test . raises ( <EOL> gaierror , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> def test_proxy_handling ( ) : <EOL> """<STR_LIT>""" <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> , <EOL> proxy = '<STR_LIT>' ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert content == b'<STR_LIT>' <EOL> assert app . success ( ) <EOL> def test_https ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert app . success ( ) <EOL> def test_https_default_port ( ) : <EOL> with InstalledApp ( wsgi_app . simple_app , host = HOST , port = <NUM_LIT> ) as app : <EOL> http = httplib2 . Http ( ) <EOL> resp , content = http . request ( <EOL> '<STR_LIT>' ) <EOL> assert app . success ( ) <EOL> environ = app . get_internals ( ) <EOL> assert environ [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def test_app_error ( ) : <EOL> with InstalledApp ( wsgi_app . raises_app , host = HOST , port = <NUM_LIT> ) : <EOL> http = httplib2 . Http ( ) <EOL> with py . test . raises ( WSGIAppError ) : <EOL> http . request ( <EOL> '<STR_LIT>' ) </s>
