From: Ben Waugh Date: Thu, 11 Apr 2013 08:52:21 +0000 (+0100) Subject: Example of using @raises to test the raising of an exception. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5f9d1952339eb6925e9bb2b10fb4409374cea017;p=swc-testing-nose.git Example of using @raises to test the raising of an exception. --- diff --git a/testing/cheat-sheet.md b/testing/cheat-sheet.md index 140e098..d7f48a0 100644 --- a/testing/cheat-sheet.md +++ b/testing/cheat-sheet.md @@ -86,9 +86,15 @@ the way values are represented and rounded. ### Testing exceptions -TODO: +Testing that a method raises the appropriate exception when the input is invalid: + + from nose.tools import raises + + from mystatscode import mean -* using `@raises` decorator + @raises(TypeError) + def test_not_a_list(): + observed = mean(1) ### Fixtures