1
"""Exception event test"""
9
class ExceptionTest(unittest.TestCase):
10
"""Exception event test"""
12
def testExceptionHandler(self):
14
class ExceptionHandler(pykd.eventHandler):
16
pykd.eventHandler.__init__(self)
18
def onException(self, exceptInfo):
19
self.exceptInfo = exceptInfo
20
return pykd.eventResult.Break
22
processId = pykd.startProcess( target.appPath + " exception" )
23
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
24
exceptionHandler = ExceptionHandler()
26
self.assertEqual( pykd.Break, pykd.go() )
27
self.assertEqual( 0xC0000005, exceptionHandler.exceptInfo.exceptionCode) #0xC0000005 = Access violation
29
def testSecondChance(self):
31
class ExceptionHandler(pykd.eventHandler):
33
pykd.eventHandler.__init__(self)
35
def onException(self, exceptInfo):
36
self.exceptInfo = exceptInfo
37
return pykd.eventResult.Proceed
39
processId = pykd.startProcess( target.appPath + " exception" )
40
with testutils.ContextCallIt( testutils.KillProcess(processId) ) as killStartedProcess :
41
exceptionHandler = ExceptionHandler()
42
self.assertEqual( pykd.Break, pykd.go() )
43
self.assertEqual( True, exceptionHandler.exceptInfo.firstChance)
44
self.assertEqual( pykd.Break, pykd.go() )
45
self.assertEqual( False, exceptionHandler.exceptInfo.firstChance)