diff options
author | Radek Novacek <rnovacek@redhat.com> | 2014-05-15 10:51:32 +0200 |
---|---|---|
committer | Radek Novacek <rnovacek@redhat.com> | 2014-05-19 10:16:35 +0200 |
commit | b88c9f32da204d277bb56ddfd79bac384bb1bcb0 (patch) | |
tree | 85c0583388925968e54ff8cfe4461697797beff3 | |
parent | c35bde30371c3a7ce78a9a92e4947f719fc48b4d (diff) | |
download | openlmi-providers-b88c9f32da204d277bb56ddfd79bac384bb1bcb0.tar.gz openlmi-providers-b88c9f32da204d277bb56ddfd79bac384bb1bcb0.tar.xz openlmi-providers-b88c9f32da204d277bb56ddfd79bac384bb1bcb0.zip |
LogicalFile: simulate subprocess check_output on python 2.6
Python 2.6 doesn't have subprocess.check_output function, we'll simulate
it using subprocess.Popen.
-rw-r--r-- | src/logicalfile/test/test_basic.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/logicalfile/test/test_basic.py b/src/logicalfile/test/test_basic.py index 3577ee2..9932187 100644 --- a/src/logicalfile/test/test_basic.py +++ b/src/logicalfile/test/test_basic.py @@ -105,6 +105,16 @@ class TestLogicalFile(LogicalFileTestBase): self._cleanup() def _prepare(self): + def check_output(command): + ''' + Python < 2.7 doesn't have subprocess check_output, simulate it + if necessary + ''' + if hasattr(subprocess, 'check_output'): + return subprocess.check_output(command) + else: + return subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0] + try: os.stat(self.testdir) except OSError: @@ -117,11 +127,11 @@ class TestLogicalFile(LogicalFileTestBase): os.chmod(data_file, 0550) if self.selinux_enabled: labels = data_props['SELinuxCurrentContext'].split(':') - out = subprocess.check_output(['chcon', '-h', + out = check_output(['chcon', '-h', '-u', labels[0], '-r', labels[1], '-t', labels[2], data_file]) - out = subprocess.check_output(['matchpathcon', '-n', data_file]) + out = check_output(['matchpathcon', '-n', data_file]) data_props['SELinuxExpectedContext'] = out[:-1] # remove \n os.mkdir(self.files['dir']['path']) os.link(data_file, self.files['hardlink']['path']) @@ -130,11 +140,11 @@ class TestLogicalFile(LogicalFileTestBase): os.symlink(data_file, slink_file) if self.selinux_enabled: labels = slink_props['SELinuxCurrentContext'].split(':') - out = subprocess.check_output(['chcon', '-h', + out = check_output(['chcon', '-h', '-u', labels[0], '-r', labels[1], '-t', labels[2], slink_file]) - out = subprocess.check_output(['matchpathcon', '-n', slink_file]) + out = check_output(['matchpathcon', '-n', slink_file]) slink_props['SELinuxExpectedContext'] = out[:-1] # remove \n os.mkfifo(self.files['fifo']['path']) chdev = self.files['chdev'] |