py3 (6) - update unit tests to py3 compatibility

This commit is contained in:
Steve Noyes 2015-11-09 16:56:46 -05:00
parent 2c6cc793a2
commit 80ff79a882
3 changed files with 14 additions and 5 deletions

View File

@ -17,10 +17,11 @@ import os
import pxssh
import subprocess
import sys
import testtools
import traceback
import yaml
import testtools
from oslo_utils.encodeutils import safe_decode
import kollacli.utils as utils
@ -47,6 +48,7 @@ class KollaCliTest(testtools.TestCase):
% self._testMethodName)
# switch to test path
self.log.info('running python: %s/%s' % (sys.executable, sys.version))
etc_path = utils.get_kollacli_etc()
self.log.debug('etc for tests: %s' % etc_path)
@ -86,11 +88,12 @@ class KollaCliTest(testtools.TestCase):
msg = e.output
except Exception as e:
retval = e.errno
retval = -1
msg = ('Unexpected exception: %s, cmd: %s'
% (traceback.format_exc(), cmd))
# the py dev debugger adds a string at the line start, remove it
msg = safe_decode(msg)
if msg.startswith('pydev debugger'):
msg = msg.split('\n', 1)[1]
return (retval, msg)
@ -233,7 +236,7 @@ class TestConfig(object):
self.hosts_info[name]['groups'].remove(group)
def get_hostnames(self):
return self.hosts_info.keys()
return list(self.hosts_info.keys())
def set_username(self, name, username):
self.hosts_info[name]['username'] = username
@ -298,6 +301,7 @@ class TestConfig(object):
session.sendline(cmd)
session.prompt()
out = session.before
out = safe_decode(out)
self.log.info(out)
session.logout()
return out

View File

@ -91,7 +91,7 @@ class TestFunctional(KollaCliTest):
# check if host is not set-up
timeout = time.time() + 75
while time.time <= timeout:
while time.time() <= timeout:
msg = self.run_cli_cmd('host check %s' % hostname, True)
if 'ERROR:' not in msg:
self.log.info('waiting for ansible ssh session to timeout')

View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = py27,pep8,bandit
envlist = py27,py34,pep8,bandit
[testenv]
usedevelop = True
@ -16,6 +16,11 @@ commands =
/usr/bin/find . -type f -name "*.pyc" -delete
{envpython} -m unittest discover -s tests -p "*.*"
[testenv:py34]
commands =
/usr/bin/find . -type f -name "*.pyc" -delete
{envpython} -m unittest discover -s tests -p "*.*"
[testenv:pep8]
commands = flake8