Update of /cvsroot/pywin32/pywin32/win32/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25522
Modified Files:
test_exceptions.py
Log Message:
More exception semantics before we get to adding attributes.
Index: test_exceptions.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/test_exceptions.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test_exceptions.py 29 Sep 2008 14:01:18 -0000 1.1
--- test_exceptions.py 30 Sep 2008 06:04:33 -0000 1.2
***************
*** 46,49 ****
--- 46,68 ----
self.failUnlessEqual(msg, expected_msg)
+ def testAsStr(self):
+ exc = self._getInvalidHandleException()
+ err_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
+ # early on the result actually *was* a tuple - it must always look like one
+ err_tuple = (winerror.ERROR_INVALID_HANDLE, 'CloseHandle', err_msg)
+ self.failUnlessEqual(str(exc), str(err_tuple))
+
+ def testAsTuple(self):
+ exc = self._getInvalidHandleException()
+ err_msg = win32api.FormatMessage(winerror.ERROR_INVALID_HANDLE).rstrip()
+ # early on the result actually *was* a tuple - it must be able to be one
+ err_tuple = (winerror.ERROR_INVALID_HANDLE, 'CloseHandle', err_msg)
+ self.failUnlessEqual(tuple(exc), err_tuple)
+
+ def testClassName(self):
+ exc = self._getInvalidHandleException()
+ # The error class has always been named 'error'. That's not ideal :(
+ self.failUnlessEqual(exc.__class__.__name__, "error")
+
class TestCOMSimple(TestBase):
def _getException(self):
***************
*** 69,72 ****
--- 88,109 ----
self._testExceptionIndex(exc, 1, expected)
+ def testAsStr(self):
+ exc = self._getException()
+ err_msg = win32api.FormatMessage(winerror.STG_E_INVALIDFLAG).rstrip()
+ # early on the result actually *was* a tuple - it must always look like one
+ err_tuple = (winerror.STG_E_INVALIDFLAG, err_msg, None, None)
+ self.failUnlessEqual(str(exc), str(err_tuple))
+
+ def testAsTuple(self):
+ exc = self._getException()
+ err_msg = win32api.FormatMessage(winerror.STG_E_INVALIDFLAG).rstrip()
+ # early on the result actually *was* a tuple - it must be able to be one
+ err_tuple = (winerror.STG_E_INVALIDFLAG, err_msg, None, None)
+ self.failUnlessEqual(tuple(exc), err_tuple)
+
+ def testClassName(self):
+ exc = self._getException()
+ self.failUnlessEqual(exc.__class__.__name__, "com_error")
+
if __name__ == '__main__':
unittest.main()
|