From 2f62736e47367404ac56525689412d123d69c283 Mon Sep 17 00:00:00 2001 From: Chang Bo Guo Date: Wed, 6 Nov 2013 04:19:37 -0800 Subject: [PATCH] Don't use deprecated module commands The commands module was deprecated since version 2.6 and it has been removed in Python 3. Use the subprocess module instead. See http://docs.python.org/2/library/commands#module-commands Closes-Bug: #1248216 Change-Id: I4091179c6b312ae8534b30adc518eff67d68320a --- cinder/tests/test_migrations.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cinder/tests/test_migrations.py b/cinder/tests/test_migrations.py index 63abae4f8..0403de938 100644 --- a/cinder/tests/test_migrations.py +++ b/cinder/tests/test_migrations.py @@ -24,9 +24,9 @@ properly both upgrading and downgrading, and that no data loss occurs if possible. """ -import commands import ConfigParser import os +import subprocess import urlparse import uuid @@ -161,9 +161,12 @@ class TestMigrations(test.TestCase): def _reset_databases(self): def execute_cmd(cmd=None): - status, output = commands.getstatusoutput(cmd) + proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, shell=True) + output = proc.communicate()[0] LOG.debug(output) - self.assertEqual(0, status) + self.assertEqual(0, proc.returncode) + for key, engine in self.engines.items(): conn_string = self.test_databases[key] conn_pieces = urlparse.urlparse(conn_string) -- 2.45.2