Improve testing in py3 environment

Change-Id: I1d169f0a87d4251778b32e80b3627b407340fec8
This commit is contained in:
Victor Sergeyev 2014-11-13 14:41:29 +02:00
parent fa52a63e4f
commit 58de317f84
3 changed files with 8 additions and 8 deletions

View File

@ -181,7 +181,7 @@ def execute(*cmd, **kwargs):
'specify a root helper.')) 'specify a root helper.'))
cmd = shlex.split(root_helper) + list(cmd) cmd = shlex.split(root_helper) + list(cmd)
cmd = map(str, cmd) cmd = [str(c) for c in cmd]
sanitized_cmd = strutils.mask_password(' '.join(cmd)) sanitized_cmd = strutils.mask_password(' '.join(cmd))
while attempts > 0: while attempts > 0:

View File

@ -142,7 +142,7 @@ exit 1
self.assertRaises(processutils.ProcessExecutionError, self.assertRaises(processutils.ProcessExecutionError,
processutils.execute, processutils.execute,
tmpfilename, tmpfilename2, attempts=10, tmpfilename, tmpfilename2, attempts=10,
process_input='foo', process_input=b'foo',
delay_on_retry=False) delay_on_retry=False)
fp = open(tmpfilename2, 'r') fp = open(tmpfilename2, 'r')
runs = fp.read() runs = fp.read()
@ -199,7 +199,7 @@ grep foo
os.chmod(tmpfilename, 0o755) os.chmod(tmpfilename, 0o755)
processutils.execute(tmpfilename, processutils.execute(tmpfilename,
tmpfilename2, tmpfilename2,
process_input='foo', process_input=b'foo',
attempts=2) attempts=2)
finally: finally:
os.unlink(tmpfilename) os.unlink(tmpfilename)
@ -295,7 +295,7 @@ grep foo
out, err = processutils.execute('/usr/bin/env', env_variables=env_vars) out, err = processutils.execute('/usr/bin/env', env_variables=env_vars)
self.assertIn('SUPER_UNIQUE_VAR=The answer is 42', out) self.assertIn(b'SUPER_UNIQUE_VAR=The answer is 42', out)
def test_exception_and_masking(self): def test_exception_and_masking(self):
tmpfilename = self.create_tempfiles( tmpfilename = self.create_tempfiles(
@ -314,8 +314,8 @@ grep foo
'something') 'something')
self.assertEqual(38, err.exit_code) self.assertEqual(38, err.exit_code)
self.assertEqual(err.stdout, 'onstdout --password="***"\n') self.assertIn('onstdout --password="***"', err.stdout)
self.assertEqual(err.stderr, 'onstderr --password="***"\n') self.assertIn('onstderr --password="***"', err.stderr)
self.assertEqual(err.cmd, ' '.join([tmpfilename, self.assertEqual(err.cmd, ' '.join([tmpfilename,
'password="***"', 'password="***"',
'something'])) 'something']))

View File

@ -23,13 +23,13 @@ commands =
deps = -r{toxinidir}/requirements-py3.txt deps = -r{toxinidir}/requirements-py3.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
lockutils-wrapper python -m testtools.run tests.unit.test_lockutils lockutils-wrapper python setup.py testr --slowest --testr-args='{posargs}'
[testenv:py34] [testenv:py34]
deps = -r{toxinidir}/requirements-py3.txt deps = -r{toxinidir}/requirements-py3.txt
-r{toxinidir}/test-requirements.txt -r{toxinidir}/test-requirements.txt
commands = commands =
lockutils-wrapper python -m testtools.run tests.unit.test_lockutils lockutils-wrapper python setup.py testr --slowest --testr-args='{posargs}'
[testenv:pep8] [testenv:pep8]
commands = flake8 commands = flake8