unit test for proxy checking

Posted by zubin71 on Stack Overflow See other posts from Stack Overflow or by zubin71
Published on 2010-04-11T12:35:03Z Indexed on 2010/04/11 12:43 UTC
Read the original article Hit count: 264

Filed under:
|
|

Proxy configuration of a machine can be easily fetched using

def check_proxy():    
     import urllib2
     http_proxy = urllib2.getproxies().get('http')

I need to write a test for the above written function. In order to do that I need to:-

  1. Set the system-wide proxy to an invalid URL during the test(sounds like a bad idea).
  2. Supply an invalid URL to http_proxy.

How can I achieve either of the above?

© Stack Overflow or respective owner

Related posts about python

Related posts about unit-testing