title: How can one mock/stub python module like urllib
body: <p>I need to test a function that needs to query a page on an external server using urllib.urlopen (it also uses urllib.urlencode). The server could be down, the page could change; I can't rely on it for a test.</p>
  
  <p>What is the best way to control what urllib.urlopen returns?</p>