Re: [Pyunit-interest] problem using assertRaises
Brought to you by:
purcell
From: Fred L. D. Jr. <fd...@ac...> - 2002-08-12 21:58:32
|
robin and jim writes: > However, test_02 does not work as expected; when the open() > operation fails, the test also fails (i.e., the exception is not > caught by assertRaises). That's because the exception is being raised before assertRaises() has been called. Try this: def test_02(self): '''handling the failure to connect with and log onto a FTP server''' self.assertRaises(Exception, self.testable.open) (Note the parens have been removed from testable.open, allowing assertRaises() to make the call, and handle the exception.) -Fred -- Fred L. Drake, Jr. <fdrake at acm.org> PythonLabs at Zope Corporation |