Back to index

python3.2  3.2.2
Public Member Functions
test.test_contextlib.LockContextTestCase Class Reference

List of all members.

Public Member Functions

def boilerPlate
def testWithLock
def testWithRLock
def testWithCondition
def testWithSemaphore
def testWithBoundedSemaphore

Detailed Description

Definition at line 158 of file test_contextlib.py.


Member Function Documentation

def test.test_contextlib.LockContextTestCase.boilerPlate (   self,
  lock,
  locked 
)

Definition at line 160 of file test_contextlib.py.

00160 
00161     def boilerPlate(self, lock, locked):
00162         self.assertFalse(locked())
00163         with lock:
00164             self.assertTrue(locked())
00165         self.assertFalse(locked())
00166         with self.assertRaises(ZeroDivisionError):
00167             with lock:
00168                 self.assertTrue(locked())
00169                 1 / 0
00170         self.assertFalse(locked())

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 195 of file test_contextlib.py.

00195 
00196     def testWithBoundedSemaphore(self):
00197         lock = threading.BoundedSemaphore()
00198         def locked():
00199             if lock.acquire(False):
00200                 lock.release()
00201                 return False
00202             else:
00203                 return True
00204         self.boilerPlate(lock, locked)
00205 

Here is the call graph for this function:

Definition at line 179 of file test_contextlib.py.

00179 
00180     def testWithCondition(self):
00181         lock = threading.Condition()
00182         def locked():
00183             return lock._is_owned()
00184         self.boilerPlate(lock, locked)

Here is the call graph for this function:

Definition at line 171 of file test_contextlib.py.

00171 
00172     def testWithLock(self):
00173         lock = threading.Lock()
00174         self.boilerPlate(lock, lock.locked)

Here is the call graph for this function:

Definition at line 175 of file test_contextlib.py.

00175 
00176     def testWithRLock(self):
00177         lock = threading.RLock()
00178         self.boilerPlate(lock, lock._is_owned)

Here is the call graph for this function:

Definition at line 185 of file test_contextlib.py.

00185 
00186     def testWithSemaphore(self):
00187         lock = threading.Semaphore()
00188         def locked():
00189             if lock.acquire(False):
00190                 lock.release()
00191                 return False
00192             else:
00193                 return True
00194         self.boilerPlate(lock, locked)

Here is the call graph for this function:


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