is left abstract in this examplebecause an uncaught exception in test case would normally kill this test driveryou need to wrap test case calls in try if you want to continue the testing process after test fails the empty except catches any uncaught exception generated by test case as usualand it uses sys exc_info to log the exception to file the else clause is run when no exception occurs--the test success case such boilerplate code is typical of systems that test functionsmodulesand classes by running them in the same process as the test driver in practicehowevertesting can be much more sophisticated than this for instanceto test external programsyou could instead check status codes or outputs generated by program-launching tools such as os system and os popenused earlier in this book and covered in the standard library manual such tools do not generally raise exceptions for errors in the external programs --in factthe test cases may run in parallel with the test driver at the end of this we'll also briefly meet more complete testing frameworks provided by pythonsuch as doctest and pyunitwhich provide tools for comparing expected outputs with actual results more on sys exc_info the sys exc_info result used in the last two sections allows an exception handler to gain access to the most recently raised exception generically this is especially useful when using the empty except clause to catch everything blindlyto determine what was raisedtryexceptsys exc_info()[ : are the exception class and instance if no exception is being handledthis call returns tuple containing three none values otherwisethe values returned are (typevaluetraceback)wheretype is the exception class of the exception being handled value is the exception class instance that was raised traceback is traceback object that represents the call stack at the point where the exception originally occurredand used by the traceback module to generate error messages as we saw in the prior sys exc_info can also sometimes be useful to determine the specific exception type when catching exception category superclasses as we've also learnedthoughbecause in this case you can also get the exception type by fetching the __class__ attribute of the instance obtained with the as clausesys exc_info is often redundant apart from the empty excepttry designing with exceptions