title: Raise warning in Python without interrupting program
body: <p>I am trying to raise a Warning in Python without making the program crash / stop / interrupt.</p>
  
  <p>I use the following simple function to check if the user passed a non-zero number to it. If so, the program should warn them, but continue as per normal. It should work like the code below, but should use class <code>Warning()</code>, <code>Error()</code> or <code>Exception()</code> instead of printing the warning out manually.</p>
  
  <pre><code>def is_zero(i):
     if i != 0:
       print "OK"
     else:
       print "WARNING: the input is 0!"
     return i
  </code></pre>
  
  <p>If I use the code below and pass 0 to the function, the program crashes and the value is never returned. Instead, I want the program to continue normally and just inform the user that he passed 0 to the function.</p>
  
  <pre><code>def is_zero(i):
     if i != 0:
       print "OK"
     else:
       raise Warning("the input is 0!")
     return i
  </code></pre>
  
  <p>I want to be able to test that a warning has been thrown testing it by unittest. If I simply print the message out, I am not able to test it with assertRaises in unittest.</p>