Make subprocess outputs to text for Python 3
This commit makes subprocess outputs to str with universal_newlines option. In Python 3, we need to do it explicitly. Otherwise an error occurs. This commit also adds a unit test to prevent regression. Change-Id: I2e428a3c57357e47c9057e8dbbbb51ae4b65e4e6
This commit is contained in:
parent
023351aef2
commit
056794cdde
|
@ -20,7 +20,7 @@ import subprocess
|
|||
def _get_test_list(regex, env=None):
|
||||
env = env or copy.deepcopy(os.environ)
|
||||
proc = subprocess.Popen(['testr', 'list-tests', regex], env=env,
|
||||
stdout=subprocess.PIPE)
|
||||
stdout=subprocess.PIPE, universal_newlines=True)
|
||||
out = proc.communicate()[0]
|
||||
raw_test_list = out.split('\n')
|
||||
bad = False
|
||||
|
|
|
@ -168,3 +168,9 @@ regex_b"""
|
|||
|
||||
expected_regex = 'regex_a|regex_b'
|
||||
self.assertEqual(result, expected_regex)
|
||||
|
||||
|
||||
class TestGetTestList(base.TestCase):
|
||||
def test__get_test_list(self):
|
||||
test_list = os_testr._get_test_list('test__get_test_list')
|
||||
self.assertIn('test__get_test_list', test_list[0])
|
||||
|
|
Loading…
Reference in New Issue