]> granicus.if.org Git - python/commitdiff
Issue #23475, asyncio: Fix test_close_kill_running()
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 17 Feb 2015 21:54:11 +0000 (22:54 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 17 Feb 2015 21:54:11 +0000 (22:54 +0100)
Really kill the child process, don't mock completly the Popen.kill() method.

This change fix memory leaks and reference leaks.

Lib/test/test_asyncio/test_subprocess.py

index de0b08af6c2b4951e77b16a276188fb350fb374f..92bf1b45edf0373b74f7389105c8f0b0ad264c9b 100644 (file)
@@ -355,11 +355,19 @@ class SubprocessMixin:
             create = self.loop.subprocess_exec(asyncio.SubprocessProtocol,
                                                *PROGRAM_BLOCKED)
             transport, protocol = yield from create
+
+            kill_called = False
+            def kill():
+                nonlocal kill_called
+                kill_called = True
+                orig_kill()
+
             proc = transport.get_extra_info('subprocess')
-            proc.kill = mock.Mock()
+            orig_kill = proc.kill
+            proc.kill = kill
             returncode = transport.get_returncode()
             transport.close()
-            return (returncode, proc.kill.called)
+            return (returncode, kill_called)
 
         # Ignore "Close running child process: kill ..." log
         with test_utils.disable_logger():