Back to index

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

List of all members.

Public Member Functions

def test_invalid_reraise
def test_reraise
def test_except_reraise
def test_finally_reraise
def test_nested_reraise
def test_with_reraise1
def test_with_reraise2
def test_yield_reraise
def test_erroneous_exception
def test_new_returns_invalid_instance

Detailed Description

Definition at line 26 of file test_raise.py.


Member Function Documentation

Definition at line 112 of file test_raise.py.

00112 
00113     def test_erroneous_exception(self):
00114         class MyException(Exception):
00115             def __init__(self):
00116                 raise RuntimeError()
00117 
00118         try:
00119             raise MyException
00120         except RuntimeError:
00121             pass
00122         else:
00123             self.fail("No exception raised")

Here is the call graph for this function:

Definition at line 47 of file test_raise.py.

00047 
00048     def test_except_reraise(self):
00049         def reraise():
00050             try:
00051                 raise TypeError("foo")
00052             except:
00053                 try:
00054                     raise KeyError("caught")
00055                 except KeyError:
00056                     pass
00057                 raise
00058         self.assertRaises(TypeError, reraise)

Here is the call graph for this function:

Definition at line 59 of file test_raise.py.

00059 
00060     def test_finally_reraise(self):
00061         def reraise():
00062             try:
00063                 raise TypeError("foo")
00064             except:
00065                 try:
00066                     raise KeyError("caught")
00067                 finally:
00068                     raise
00069         self.assertRaises(KeyError, reraise)

Here is the call graph for this function:

Definition at line 27 of file test_raise.py.

00027 
00028     def test_invalid_reraise(self):
00029         try:
00030             raise
00031         except RuntimeError as e:
00032             self.assertIn("No active exception", str(e))
00033         else:
00034             self.fail("No exception raised")

Here is the call graph for this function:

Definition at line 70 of file test_raise.py.

00070 
00071     def test_nested_reraise(self):
00072         def nested_reraise():
00073             raise
00074         def reraise():
00075             try:
00076                 raise TypeError("foo")
00077             except:
00078                 nested_reraise()
00079         self.assertRaises(TypeError, reraise)

Definition at line 124 of file test_raise.py.

00124 
00125     def test_new_returns_invalid_instance(self):
00126         # See issue #11627.
00127         class MyException(Exception):
00128             def __new__(cls, *args):
00129                 return object()
00130 
00131         with self.assertRaises(TypeError):
00132             raise MyException
00133 

Here is the call graph for this function:

Definition at line 35 of file test_raise.py.

00035 
00036     def test_reraise(self):
00037         try:
00038             try:
00039                 raise IndexError()
00040             except IndexError as e:
00041                 exc1 = e
00042                 raise
00043         except IndexError as exc2:
00044             self.assertTrue(exc1 is exc2)
00045         else:
00046             self.fail("No exception raised")

Here is the call graph for this function:

Definition at line 80 of file test_raise.py.

00080 
00081     def test_with_reraise1(self):
00082         def reraise():
00083             try:
00084                 raise TypeError("foo")
00085             except:
00086                 with Context():
00087                     pass
00088                 raise
00089         self.assertRaises(TypeError, reraise)

Here is the call graph for this function:

Definition at line 90 of file test_raise.py.

00090 
00091     def test_with_reraise2(self):
00092         def reraise():
00093             try:
00094                 raise TypeError("foo")
00095             except:
00096                 with Context():
00097                     raise KeyError("caught")
00098                 raise
00099         self.assertRaises(TypeError, reraise)

Here is the call graph for this function:

Definition at line 100 of file test_raise.py.

00100 
00101     def test_yield_reraise(self):
00102         def reraise():
00103             try:
00104                 raise TypeError("foo")
00105             except:
00106                 yield 1
00107                 raise
00108         g = reraise()
00109         next(g)
00110         self.assertRaises(TypeError, lambda: next(g))
00111         self.assertRaises(StopIteration, lambda: next(g))

Here is the call graph for this function:


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