title: How to test with Python's unittest that a warning has been thrown?
body: <p>I have a following function in Python and I want to test with unittest that if the function gets 0 as argument, it throws a warning. I already tried assertRaises, but since I don't raise the warning, that doesn't work. </p>
  
  <pre><code>def isZero(i):
      if i != 0:
          print "OK"
      else:
          warning = Warning("the input is 0!") 
          print warning
      return i
  </code></pre>