Back to index

python3.2  3.2.2
Public Member Functions
test.test_sched.TestCase Class Reference

List of all members.

Public Member Functions

def test_enter
def test_enterabs
def test_priority
def test_cancel
def test_empty
def test_queue

Detailed Description

Definition at line 9 of file test_sched.py.


Member Function Documentation

Definition at line 38 of file test_sched.py.

00038 
00039     def test_cancel(self):
00040         l = []
00041         fun = lambda x: l.append(x)
00042         scheduler = sched.scheduler(time.time, time.sleep)
00043         event1 = scheduler.enter(0.01, 1, fun, (0.01,))
00044         event2 = scheduler.enter(0.02, 1, fun, (0.02,))
00045         event3 = scheduler.enter(0.03, 1, fun, (0.03,))
00046         event4 = scheduler.enter(0.04, 1, fun, (0.04,))
00047         event5 = scheduler.enter(0.05, 1, fun, (0.05,))
00048         scheduler.cancel(event1)
00049         scheduler.cancel(event5)
00050         scheduler.run()
00051         self.assertEqual(l, [0.02, 0.03, 0.04])

Here is the call graph for this function:

Definition at line 52 of file test_sched.py.

00052 
00053     def test_empty(self):
00054         l = []
00055         fun = lambda x: l.append(x)
00056         scheduler = sched.scheduler(time.time, time.sleep)
00057         self.assertTrue(scheduler.empty())
00058         for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
00059             z = scheduler.enterabs(x, 1, fun, (x,))
00060         self.assertFalse(scheduler.empty())
00061         scheduler.run()
00062         self.assertTrue(scheduler.empty())

Here is the call graph for this function:

Definition at line 11 of file test_sched.py.

00011 
00012     def test_enter(self):
00013         l = []
00014         fun = lambda x: l.append(x)
00015         scheduler = sched.scheduler(time.time, time.sleep)
00016         for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
00017             z = scheduler.enter(x, 1, fun, (x,))
00018         scheduler.run()
00019         self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])

Here is the call graph for this function:

Definition at line 20 of file test_sched.py.

00020 
00021     def test_enterabs(self):
00022         l = []
00023         fun = lambda x: l.append(x)
00024         scheduler = sched.scheduler(time.time, time.sleep)
00025         for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
00026             z = scheduler.enterabs(x, 1, fun, (x,))
00027         scheduler.run()
00028         self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])

Here is the call graph for this function:

Definition at line 29 of file test_sched.py.

00029 
00030     def test_priority(self):
00031         l = []
00032         fun = lambda x: l.append(x)
00033         scheduler = sched.scheduler(time.time, time.sleep)
00034         for priority in [1, 2, 3, 4, 5]:
00035             z = scheduler.enter(0.01, priority, fun, (priority,))
00036         scheduler.run()
00037         self.assertEqual(l, [1, 2, 3, 4, 5])

Here is the call graph for this function:

Definition at line 63 of file test_sched.py.

00063 
00064     def test_queue(self):
00065         l = []
00066         events = []
00067         fun = lambda x: l.append(x)
00068         scheduler = sched.scheduler(time.time, time.sleep)
00069         self.assertEqual(scheduler._queue, [])
00070         for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
00071             events.append(scheduler.enterabs(x, 1, fun, (x,)))
00072         self.assertEqual(scheduler._queue.sort(), events.sort())
00073         scheduler.run()
00074         self.assertEqual(scheduler._queue, [])
00075 

Here is the call graph for this function:


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