summaryrefslogtreecommitdiff
path: root/Lib/test/test_concurrent_futures.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-04-01 09:16:35 +0300
committerGitHub <noreply@github.com>2019-04-01 09:16:35 +0300
commit42a139ed88c487f325a241c6ee8b308b3c045975 (patch)
treede56527188eff240b06496c3451e525af959dcad /Lib/test/test_concurrent_futures.py
parent5f2c50810a67982b0c80f6d3258fee3647f67005 (diff)
downloadcpython-git-42a139ed88c487f325a241c6ee8b308b3c045975.tar.gz
bpo-36492: Deprecate passing some arguments as keyword arguments. (GH-12637)
Deprecated passing the following arguments as keyword arguments: - "func" in functools.partialmethod(), weakref.finalize(), profile.Profile.runcall(), cProfile.Profile.runcall(), bdb.Bdb.runcall(), trace.Trace.runfunc() and curses.wrapper(). - "function" in unittest.addModuleCleanup() and unittest.TestCase.addCleanup(). - "fn" in the submit() method of concurrent.futures.ThreadPoolExecutor and concurrent.futures.ProcessPoolExecutor. - "callback" in contextlib.ExitStack.callback(), contextlib.AsyncExitStack.callback() and contextlib.AsyncExitStack.push_async_callback(). - "c" and "typeid" in the create() method of multiprocessing.managers.Server and multiprocessing.managers.SharedMemoryServer. - "obj" in weakref.finalize(). Also allowed to pass arbitrary keyword arguments (even "self" and "func") if the above arguments are passed as positional argument.
Diffstat (limited to 'Lib/test/test_concurrent_futures.py')
-rw-r--r--Lib/test/test_concurrent_futures.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
index 01125c79ba..903afbd2a4 100644
--- a/Lib/test/test_concurrent_futures.py
+++ b/Lib/test/test_concurrent_futures.py
@@ -49,6 +49,9 @@ INITIALIZER_STATUS = 'uninitialized'
def mul(x, y):
return x * y
+def capture(*args, **kwargs):
+ return args, kwargs
+
def sleep_and_raise(t):
time.sleep(t)
raise Exception('this is an exception')
@@ -658,6 +661,13 @@ class ExecutorTest:
def test_submit_keyword(self):
future = self.executor.submit(mul, 2, y=8)
self.assertEqual(16, future.result())
+ future = self.executor.submit(capture, 1, self=2, fn=3)
+ self.assertEqual(future.result(), ((1,), {'self': 2, 'fn': 3}))
+ with self.assertWarns(DeprecationWarning):
+ future = self.executor.submit(fn=capture, arg=1)
+ self.assertEqual(future.result(), ((), {'arg': 1}))
+ with self.assertRaises(TypeError):
+ self.executor.submit(arg=1)
def test_map(self):
self.assertEqual(