summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGiampaolo Rodola' <g.rodola@gmail.com>2011-11-26 11:17:42 (GMT)
committerGiampaolo Rodola' <g.rodola@gmail.com>2011-11-26 11:17:42 (GMT)
commit6a5dcd4b2aa3f4c39749056750329cd69d849435 (patch)
tree1afe601becc1605401f8f789ea1b0b6f09312363 /Lib
parent2966f10ec0a75ae62947df08c7a83ba50e766750 (diff)
downloadcpython-6a5dcd4b2aa3f4c39749056750329cd69d849435.zip
cpython-6a5dcd4b2aa3f4c39749056750329cd69d849435.tar.gz
cpython-6a5dcd4b2aa3f4c39749056750329cd69d849435.tar.bz2
sched.py: fix test_queue by making sure that queue property returns an orderd list of upcoming events
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_sched.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
index 1af43cb..f5e159d 100644
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -62,15 +62,16 @@ class TestCase(unittest.TestCase):
def test_queue(self):
l = []
- events = []
fun = lambda x: l.append(x)
scheduler = sched.scheduler(time.time, time.sleep)
- self.assertEqual(scheduler._queue, [])
- for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
- events.append(scheduler.enterabs(x, 1, fun, (x,)))
- self.assertEqual(scheduler._queue.sort(), events.sort())
- scheduler.run()
- self.assertEqual(scheduler._queue, [])
+ e5 = scheduler.enter(0.05, 1, fun)
+ e1 = scheduler.enter(0.01, 1, fun)
+ e2 = scheduler.enter(0.02, 1, fun)
+ e4 = scheduler.enter(0.04, 1, fun)
+ e3 = scheduler.enter(0.03, 1, fun)
+ # queue property is supposed to return an order list of
+ # upcoming events
+ self.assertEqual(list(scheduler.queue), [e1, e2, e3, e4, e5])
def test_args_kwargs(self):
flag = []