From 5f9d1952339eb6925e9bb2b10fb4409374cea017 Mon Sep 17 00:00:00 2001 From: Ben Waugh Date: Thu, 11 Apr 2013 09:52:21 +0100 Subject: [PATCH] Example of using @raises to test the raising of an exception. --- testing/cheat-sheet.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 -- 2.26.2