summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2018-06-08 12:11:31 -0400
committerScott Moser <smoser@brickies.net>2018-06-08 12:11:31 -0400
commit9a41fce0c2399f05b2c904948c969623dc04e491 (patch)
treebc6b750f7b30e85de8402ed05a03028a337e160e /tests
parent4c568f220b65dbc1af822ccfa0f31638fed02d83 (diff)
downloadvyos-cloud-init-9a41fce0c2399f05b2c904948c969623dc04e491.tar.gz
vyos-cloud-init-9a41fce0c2399f05b2c904948c969623dc04e491.zip
subp: support combine_capture argument.
This adds 'combine_capture' argument as was present in curtin's subp. It is useful to get interleaved output of a command. I noticed a need for it when looking at user_data_rhevm in DataSourceAltCloud. That will run a subcommand, logging its stdout but swallowing its stderr. Another thing to change to use this would be in udevadm_settle which currently just returns the subp() call. Also, add the docstring copied from curtin's subp.
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_util.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index d774f3dc..2db8e3fa 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -829,6 +829,14 @@ class TestSubp(helpers.CiTestCase):
r'Missing #! in script\?',
util.subp, (noshebang,))
+ def test_subp_combined_stderr_stdout(self):
+ """Providing combine_capture as True redirects stderr to stdout."""
+ data = b'hello world'
+ (out, err) = util.subp(self.stdin2err, capture=True,
+ combine_capture=True, decode=False, data=data)
+ self.assertEqual(b'', err)
+ self.assertEqual(data, out)
+
def test_returns_none_if_no_capture(self):
(out, err) = util.subp(self.stdin2out, data=b'', capture=False)
self.assertIsNone(err)