mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
asyncio: subprocess_shell() and subprocess_exec() now raise ValueError instead of assert.
Moreover, bufsize different than 0 is now considered as an error.
This commit is contained in:
parent
73f10fd2f1
commit
e623a12297
2 changed files with 46 additions and 5 deletions
|
@ -1491,6 +1491,38 @@ class SubprocessTestsMixin:
|
|||
self.loop.run_until_complete(proto.completed)
|
||||
self.assertEqual(7, proto.returncode)
|
||||
|
||||
def test_subprocess_exec_invalid_args(self):
|
||||
@asyncio.coroutine
|
||||
def connect(**kwds):
|
||||
yield from self.loop.subprocess_exec(
|
||||
asyncio.SubprocessProtocol,
|
||||
'pwd', **kwds)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(universal_newlines=True))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(bufsize=4096))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(shell=True))
|
||||
|
||||
def test_subprocess_shell_invalid_args(self):
|
||||
@asyncio.coroutine
|
||||
def connect(cmd=None, **kwds):
|
||||
if not cmd:
|
||||
cmd = 'pwd'
|
||||
yield from self.loop.subprocess_shell(
|
||||
asyncio.SubprocessProtocol,
|
||||
cmd, **kwds)
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(['ls', '-l']))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(universal_newlines=True))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(bufsize=4096))
|
||||
with self.assertRaises(ValueError):
|
||||
self.loop.run_until_complete(connect(shell=False))
|
||||
|
||||
|
||||
if sys.platform == 'win32':
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue