summaryrefslogtreecommitdiff
path: root/Lib/test/test_sched.py
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
committerSteve Dower <steve.dower@microsoft.com>2017-02-04 15:05:40 -0800
commitb2fa705fd3887c326e811c418469c784353027f4 (patch)
treeb3428f73de91453edbfd4df1a5d4a212d182eb44 /Lib/test/test_sched.py
parent134e58fd3aaa2e91390041e143f3f0a21a60142b (diff)
parentb53654b6dbfce8318a7d4d1cdaddca7a7fec194b (diff)
downloadcpython-b2fa705fd3887c326e811c418469c784353027f4.tar.gz
Issue #29392: Prevent crash when passing invalid arguments into msvcrt module.
Diffstat (limited to 'Lib/test/test_sched.py')
-rw-r--r--Lib/test/test_sched.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
index fe8e785092..ebf8856462 100644
--- a/Lib/test/test_sched.py
+++ b/Lib/test/test_sched.py
@@ -2,7 +2,6 @@ import queue
import sched
import time
import unittest
-from test import support
try:
import threading
except ImportError:
@@ -173,17 +172,23 @@ class TestCase(unittest.TestCase):
self.assertEqual(scheduler.queue, [e1, e2, e3, e4, e5])
def test_args_kwargs(self):
- flag = []
-
+ seq = []
def fun(*a, **b):
- flag.append(None)
- self.assertEqual(a, (1,2,3))
- self.assertEqual(b, {"foo":1})
+ seq.append((a, b))
+ now = time.time()
scheduler = sched.scheduler(time.time, time.sleep)
- z = scheduler.enterabs(0.01, 1, fun, argument=(1,2,3), kwargs={"foo":1})
+ scheduler.enterabs(now, 1, fun)
+ scheduler.enterabs(now, 1, fun, argument=(1, 2))
+ scheduler.enterabs(now, 1, fun, argument=('a', 'b'))
+ scheduler.enterabs(now, 1, fun, argument=(1, 2), kwargs={"foo": 3})
scheduler.run()
- self.assertEqual(flag, [None])
+ self.assertCountEqual(seq, [
+ ((), {}),
+ ((1, 2), {}),
+ (('a', 'b'), {}),
+ ((1, 2), {'foo': 3})
+ ])
def test_run_non_blocking(self):
l = []