summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_subprocess.py
diff options
context:
space:
mode:
authorNiklas Fiekas <niklas.fiekas@backscattering.de>2019-05-20 12:02:17 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-20 12:02:16 (GMT)
commit9932fd91e878b740704ff599522e945a4bbe2ae1 (patch)
tree2aa24d867fc52f03e9312cd8617a12263f84c150 /Lib/test/test_asyncio/test_subprocess.py
parent6d1c46746e17367caf8a24623cb5c9a9c4e3e036 (diff)
downloadcpython-9932fd91e878b740704ff599522e945a4bbe2ae1.zip
cpython-9932fd91e878b740704ff599522e945a4bbe2ae1.tar.gz
cpython-9932fd91e878b740704ff599522e945a4bbe2ae1.tar.bz2
bpo-35721: Close socket pair if Popen in _UnixSubprocessTransport fails (GH-11553)
This slightly expands an existing test case `test_popen_error` to trigger a `ResourceWarning` and fixes it. https://bugs.python.org/issue35721
Diffstat (limited to 'Lib/test/test_asyncio/test_subprocess.py')
-rw-r--r--Lib/test/test_asyncio/test_subprocess.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_subprocess.py b/Lib/test/test_asyncio/test_subprocess.py
index 3908aab..551974a 100644
--- a/Lib/test/test_asyncio/test_subprocess.py
+++ b/Lib/test/test_asyncio/test_subprocess.py
@@ -468,9 +468,7 @@ class SubprocessMixin:
isinstance(self, SubprocessFastWatcherTests)):
asyncio.get_child_watcher()._callbacks.clear()
- def test_popen_error(self):
- # Issue #24763: check that the subprocess transport is closed
- # when BaseSubprocessTransport fails
+ def _test_popen_error(self, stdin):
if sys.platform == 'win32':
target = 'asyncio.windows_utils.Popen'
else:
@@ -480,12 +478,23 @@ class SubprocessMixin:
popen.side_effect = exc
create = asyncio.create_subprocess_exec(sys.executable, '-c',
- 'pass', loop=self.loop)
+ 'pass', stdin=stdin,
+ loop=self.loop)
with warnings.catch_warnings(record=True) as warns:
with self.assertRaises(exc):
self.loop.run_until_complete(create)
self.assertEqual(warns, [])
+ def test_popen_error(self):
+ # Issue #24763: check that the subprocess transport is closed
+ # when BaseSubprocessTransport fails
+ self._test_popen_error(stdin=None)
+
+ def test_popen_error_with_stdin_pipe(self):
+ # Issue #35721: check that newly created socket pair is closed when
+ # Popen fails
+ self._test_popen_error(stdin=subprocess.PIPE)
+
def test_read_stdout_after_process_exit(self):
async def execute():