Back to index

python3.2  3.2.2
Public Member Functions
test.test_with.NonLocalFlowControlTestCase Class Reference

List of all members.

Public Member Functions

def testWithBreak
def testWithContinue
def testWithReturn
def testWithYield
def testWithRaise

Detailed Description

Definition at line 546 of file test_with.py.


Member Function Documentation

Definition at line 548 of file test_with.py.

00548 
00549     def testWithBreak(self):
00550         counter = 0
00551         while True:
00552             counter += 1
00553             with mock_contextmanager_generator():
00554                 counter += 10
00555                 break
00556             counter += 100 # Not reached
00557         self.assertEqual(counter, 11)

Here is the call graph for this function:

Definition at line 558 of file test_with.py.

00558 
00559     def testWithContinue(self):
00560         counter = 0
00561         while True:
00562             counter += 1
00563             if counter > 2:
00564                 break
00565             with mock_contextmanager_generator():
00566                 counter += 10
00567                 continue
00568             counter += 100 # Not reached
00569         self.assertEqual(counter, 12)

Here is the call graph for this function:

Definition at line 589 of file test_with.py.

00589 
00590     def testWithRaise(self):
00591         counter = 0
00592         try:
00593             counter += 1
00594             with mock_contextmanager_generator():
00595                 counter += 10
00596                 raise RuntimeError
00597             counter += 100 # Not reached
00598         except RuntimeError:
00599             self.assertEqual(counter, 11)
00600         else:
00601             self.fail("Didn't raise RuntimeError")
00602 

Here is the call graph for this function:

Definition at line 570 of file test_with.py.

00570 
00571     def testWithReturn(self):
00572         def foo():
00573             counter = 0
00574             while True:
00575                 counter += 1
00576                 with mock_contextmanager_generator():
00577                     counter += 10
00578                     return counter
00579                 counter += 100 # Not reached
00580         self.assertEqual(foo(), 11)

Here is the call graph for this function:

Definition at line 581 of file test_with.py.

00581 
00582     def testWithYield(self):
00583         def gen():
00584             with mock_contextmanager_generator():
00585                 yield 12
00586                 yield 13
00587         x = list(gen())
00588         self.assertEqual(x, [12, 13])

Here is the call graph for this function:


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