Back to index

python3.2  3.2.2
Public Member Functions
test.test_raise.TestCause Class Reference

List of all members.

Public Member Functions

def test_invalid_cause
def test_class_cause
def test_instance_cause
def test_erroneous_cause

Detailed Description

Definition at line 134 of file test_raise.py.


Member Function Documentation

Definition at line 143 of file test_raise.py.

00143 
00144     def test_class_cause(self):
00145         try:
00146             raise IndexError from KeyError
00147         except IndexError as e:
00148             self.assertIsInstance(e.__cause__, KeyError)
00149         else:
00150             self.fail("No exception raised")

Here is the call graph for this function:

Definition at line 160 of file test_raise.py.

00160 
00161     def test_erroneous_cause(self):
00162         class MyException(Exception):
00163             def __init__(self):
00164                 raise RuntimeError()
00165 
00166         try:
00167             raise IndexError from MyException
00168         except RuntimeError:
00169             pass
00170         else:
00171             self.fail("No exception raised")
00172 

Here is the call graph for this function:

Definition at line 151 of file test_raise.py.

00151 
00152     def test_instance_cause(self):
00153         cause = KeyError()
00154         try:
00155             raise IndexError from cause
00156         except IndexError as e:
00157             self.assertTrue(e.__cause__ is cause)
00158         else:
00159             self.fail("No exception raised")

Here is the call graph for this function:

Definition at line 135 of file test_raise.py.

00135 
00136     def test_invalid_cause(self):
00137         try:
00138             raise IndexError from 5
00139         except TypeError as e:
00140             self.assertIn("exception cause", str(e))
00141         else:
00142             self.fail("No exception raised")

Here is the call graph for this function:


The documentation for this class was generated from the following file: