summaryrefslogtreecommitdiffstats
path: root/ipatests/test_cmdline
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2015-11-25 17:17:18 +0100
committerJan Cholasta <jcholast@redhat.com>2015-12-14 10:54:23 +0100
commit099cf98307d4b2f0ace5d5e28754f264808bf59d (patch)
treea2cfad681ef3e0adf47afdd0810e69d760fa07bf /ipatests/test_cmdline
parent4cc206b0f82dd68d615f0aebba5b03acf127f53a (diff)
downloadfreeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.tar.gz
freeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.tar.xz
freeipa-099cf98307d4b2f0ace5d5e28754f264808bf59d.zip
Refactor ipautil.run
The ipautil.run function now returns an object with returncode and output are accessible as attributes. The stdout and stderr of all commands are logged (unless skip_output is given). The stdout/stderr contents must be explicitly requested with a keyword argument, otherwise they are None. This is because in Python 3, the output needs to be decoded, and that can fail if it's not decodable (human-readable) text. The raw (bytes) output is always available from the result object, as is "leniently" decoded output suitable for logging. All calls are changed to reflect this. A use of Popen in cainstance is changed to ipautil.run. Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipatests/test_cmdline')
-rw-r--r--ipatests/test_cmdline/test_ipagetkeytab.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/ipatests/test_cmdline/test_ipagetkeytab.py b/ipatests/test_cmdline/test_ipagetkeytab.py
index d903305ed..2df9b6eb2 100644
--- a/ipatests/test_cmdline/test_ipagetkeytab.py
+++ b/ipatests/test_cmdline/test_ipagetkeytab.py
@@ -85,8 +85,11 @@ class test_ipagetkeytab(cmdline_test):
"-p", "test/notfound.example.com",
"-k", self.keytabname,
]
- (out, err, rc) = ipautil.run(new_args, stdin=None, raiseonerr=False)
+ result = ipautil.run(new_args, stdin=None, raiseonerr=False,
+ capture_error=True)
+ err = result.error_output
assert 'Failed to parse result: PrincipalName not found.\n' in err, err
+ rc = result.returncode
assert rc > 0, rc
def test_2_run(self):
@@ -107,10 +110,11 @@ class test_ipagetkeytab(cmdline_test):
"-k", self.keytabname,
]
try:
- (out, err, rc) = ipautil.run(new_args, None)
+ result = ipautil.run(new_args, None, capture_error=True)
expected = 'Keytab successfully retrieved and stored in: %s\n' % (
self.keytabname)
- assert expected in err, 'Success message not in output:\n%s' % err
+ assert (expected in result.error_output,
+ 'Success message not in output:\n%s' % result.error_output)
except ipautil.CalledProcessError as e:
assert (False)