enodyt.zapzarap.net/blog

nose: Testing for Exceptions #

python — enodyt @ 15.06.2009 12:13

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()

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

(c) 2010 enodyt.zapzarap.net/blog | powered by WordPress, running in doloops