Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(206591)

Unified Diff: Lib/test/test_threading.py

Issue 17435: threading.Timer.__init__() should use immutable argument defaults for args and kwargs
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Doc/library/threading.rst ('k') | Lib/threading.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_threading.py Wed Mar 13 02:27:53 2013 +0200
+++ b/Lib/test/test_threading.py Fri Mar 15 19:58:29 2013 -0400
@@ -787,6 +787,29 @@
self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode())
self.assertEqual(data, expected_output)
+class TimerTests(BaseTestCase):
+
+ def setUp(self):
+ BaseTestCase.setUp(self)
+ self.callback_invocations = []
+ self.callback_event = threading.Event()
+
+ def test_init_immutable_default_args(self):
+ timer1 = threading.Timer(1, self._callback_spy)
+ timer1.args.append("blah")
+ timer1.kwargs["foo"] = "bar"
+ timer2 = threading.Timer(1, self._callback_spy)
+ timer2.start()
+ self.callback_event.wait()
+ self.assertEquals(len(self.callback_invocations), 1)
+ (invocation_args, invocation_kwargs) = self.callback_invocations[0]
+ self.assertEquals(invocation_args, ())
+ self.assertEquals(invocation_kwargs, {})
+
+ def _callback_spy(self, *args, **kwargs):
+ self.callback_invocations.append((args, kwargs))
+ self.callback_event.set()
+
class LockTests(lock_tests.LockTests):
locktype = staticmethod(threading.Lock)
« no previous file with comments | « Doc/library/threading.rst ('k') | Lib/threading.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+