Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.lock_tests.EventTests Class Reference
Inheritance diagram for test.lock_tests.EventTests:
Inheritance graph
[legend]
Collaboration diagram for test.lock_tests.EventTests:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_is_set
def test_notify
def test_timeout
def setUp
def tearDown
def assertTimeout

Private Member Functions

def _check_notify

Detailed Description

Tests for Event objects.

Definition at line 287 of file lock_tests.py.


Member Function Documentation

def test.lock_tests.EventTests._check_notify (   self,
  evt 
) [private]

Definition at line 304 of file lock_tests.py.

00304 
00305     def _check_notify(self, evt):
00306         # All threads get notified
00307         N = 5
00308         results1 = []
00309         results2 = []
00310         def f():
00311             results1.append(evt.wait())
00312             results2.append(evt.wait())
00313         b = Bunch(f, N)
00314         b.wait_for_started()
00315         _wait()
00316         self.assertEqual(len(results1), 0)
00317         evt.set()
00318         b.wait_for_finished()
00319         self.assertEqual(results1, [True] * N)
00320         self.assertEqual(results2, [True] * N)

Here is the call graph for this function:

Here is the caller graph for this function:

def test.lock_tests.BaseTestCase.assertTimeout (   self,
  actual,
  expected 
) [inherited]

Definition at line 65 of file lock_tests.py.

00065 
00066     def assertTimeout(self, actual, expected):
00067         # The waiting and/or time.time() can be imprecise, which
00068         # is why comparing to the expected value would sometimes fail
00069         # (especially under Windows).
00070         self.assertGreaterEqual(actual, expected * 0.6)
00071         # Test nothing insane happened
00072         self.assertLess(actual, expected * 10.0)
00073 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.lock_tests.BaseTestCase.setUp (   self) [inherited]

Reimplemented in test.lock_tests.BarrierTests.

Definition at line 58 of file lock_tests.py.

00058 
00059     def setUp(self):
00060         self._threads = support.threading_setup()

Here is the caller graph for this function:

def test.lock_tests.BaseTestCase.tearDown (   self) [inherited]

Reimplemented in test.lock_tests.BarrierTests.

Definition at line 61 of file lock_tests.py.

00061 
00062     def tearDown(self):
00063         support.threading_cleanup(*self._threads)
00064         support.reap_children()

Here is the caller graph for this function:

Definition at line 292 of file lock_tests.py.

00292 
00293     def test_is_set(self):
00294         evt = self.eventtype()
00295         self.assertFalse(evt.is_set())
00296         evt.set()
00297         self.assertTrue(evt.is_set())
00298         evt.set()
00299         self.assertTrue(evt.is_set())
00300         evt.clear()
00301         self.assertFalse(evt.is_set())
00302         evt.clear()
00303         self.assertFalse(evt.is_set())

Here is the call graph for this function:

Definition at line 321 of file lock_tests.py.

00321 
00322     def test_notify(self):
00323         evt = self.eventtype()
00324         self._check_notify(evt)
00325         # Another time, after an explicit clear()
00326         evt.set()
00327         evt.clear()
00328         self._check_notify(evt)

Here is the call graph for this function:

Definition at line 329 of file lock_tests.py.

00329 
00330     def test_timeout(self):
00331         evt = self.eventtype()
00332         results1 = []
00333         results2 = []
00334         N = 5
00335         def f():
00336             results1.append(evt.wait(0.0))
00337             t1 = time.time()
00338             r = evt.wait(0.5)
00339             t2 = time.time()
00340             results2.append((r, t2 - t1))
00341         Bunch(f, N).wait_for_finished()
00342         self.assertEqual(results1, [False] * N)
00343         for r, dt in results2:
00344             self.assertFalse(r)
00345             self.assertTimeout(dt, 0.5)
00346         # The event is set
00347         results1 = []
00348         results2 = []
00349         evt.set()
00350         Bunch(f, N).wait_for_finished()
00351         self.assertEqual(results1, [True] * N)
00352         for r, dt in results2:
00353             self.assertTrue(r)
00354 

Here is the call graph for this function:


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