nose: Testing for Exceptions #
Mit dem Python-Testframework nose und dessen raises-Decorator lässt es sich sehr elegant auf Exceptions testen:
# super.py
def superfunc():
raise Exception("Ooops! Super!")
# test_super.py
from nose.tools import raises
@raises(Exception)
def test_superfunc():
superfunc()