[Tutor] Writing unit tests that involve email

Peter Otten __peter__ at web.de
Wed Jul 17 08:36:55 CEST 2013


Arnel Legaspi wrote:

> class TestReadingSendingPostFile(unittest.TestCase):

>       def test_wrongconfigfile(self):
>           clear_args()
>           add_testfiles('post.md', 'bloginfo.ini')
>           self.assertRaises(IOError)

Where did you catch up that idiom? The assertRaises() call above does 
nothing. You must either invoke it with a callable

self.assertRaises(IOError, function_supposed_to_raise)

or use it as a context manager

with self.assertRaises(IOError):
    ... # code supposed to raise an IOError




More information about the Tutor mailing list