[Pyunit-interest] problem using assertRaises
Brought to you by:
purcell
From: robin a. j. <rob...@ea...> - 2002-08-12 21:30:53
|
Hello, I'm using the unittest module shipped with PythonWin 2.2.1, and I am = having trouble using assertRaises. Here is a code fragment example. def test_01(self): '''handling the failure to connect with and log onto a FTP = server''' try: self.testable.open() except Exception: pass else: self.fail('exception not raised') def test_02(self): '''handling the failure to connect with and log onto a FTP = server''' self.assertRaises(Exception, self.testable.open()) test_01 works as expected (i.e., when the open() operation fails, the = test succeeds). 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). What am I doing wrong? |