diff --git a/.gitignore b/.gitignore index 7947e2f..c94de0a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ bin *.py[oc] *.pyc func-results.json +.stestr diff --git a/.zuul.yaml b/.zuul.yaml index aa9c508..7051aee 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,4 +1,3 @@ - project: templates: - - python-charm-jobs - - openstack-python35-jobs-nonvoting + - python35-charm-jobs diff --git a/hooks/cinder_backup_hooks.py b/hooks/cinder_backup_hooks.py index 083b19e..aa2ac3e 100755 --- a/hooks/cinder_backup_hooks.py +++ b/hooks/cinder_backup_hooks.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # # Copyright 2016 Canonical Ltd # diff --git a/hooks/cinder_backup_utils.py b/hooks/cinder_backup_utils.py index 9621a0f..ce413d4 100644 --- a/hooks/cinder_backup_utils.py +++ b/hooks/cinder_backup_utils.py @@ -99,7 +99,7 @@ def restart_map(): that should be restarted when file changes. """ _map = [] - for f, ctxt in CONFIG_FILES.iteritems(): + for f, ctxt in CONFIG_FILES.items(): svcs = [] for svc in ctxt['services']: svcs.append(svc) @@ -111,9 +111,10 @@ def restart_map(): def set_ceph_env_variables(service): # XXX: Horrid kludge to make cinder-backup use # a different ceph username than admin - env = open('/etc/environment', 'r').read() + with open('/etc/environment', 'rt') as f: + env = f.read() if 'CEPH_ARGS' not in env: - with open('/etc/environment', 'a') as out: + with open('/etc/environment', 'at') as out: out.write('CEPH_ARGS="--id %s"\n' % service) - with open('/etc/init/cinder-backup.override', 'w') as out: + with open('/etc/init/cinder-backup.override', 'wt') as out: out.write('env CEPH_ARGS="--id %s"\n' % service) diff --git a/tests/basic_deployment.py b/tests/basic_deployment.py index 29ce31b..d28f784 100644 --- a/tests/basic_deployment.py +++ b/tests/basic_deployment.py @@ -745,7 +745,7 @@ class CinderBackupBasicDeployment(OpenStackAmuletDeployment): # NOTE(hopem): it appears that at some point cinder-backup stopped # restoring volume metadata properly so revert to default name if # original is not found - name = "restore_backup_%s" % (vol_backup.id) + name = "restore_backup_{}".format(vol_backup.id) try: cinder_vols = [v for v in vols if v.name == name] except AttributeError: @@ -753,11 +753,11 @@ class CinderBackupBasicDeployment(OpenStackAmuletDeployment): if not cinder_vols: try: - msg = ("Could not find restore vol '%s' in %s" % - (name, [v.name for v in vols])) + msg = ("Could not find restore vol '{}' in {}" + .format(name, [v.name for v in vols])) except AttributeError: - msg = ("Could not find restore vol '%s' in %s" % - (name, [v.display_name for v in vols])) + msg = ("Could not find restore vol '{}' in {}" + .format(name, [v.display_name for v in vols])) u.log.error(msg) amulet.raise_status(amulet.FAIL, msg=msg) diff --git a/tox.ini b/tox.ini index 0b72fa9..1457901 100644 --- a/tox.ini +++ b/tox.ini @@ -2,7 +2,7 @@ # This file is managed centrally by release-tools and should not be modified # within individual charm repos. [tox] -envlist = pep8,py27 +envlist = pep8,py3{5,6} skipsdist = True [testenv] @@ -20,6 +20,7 @@ passenv = HOME TERM AMULET_* CS_API_* basepython = python2.7 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt +commands = /bin/true [testenv:py35] basepython = python3.5 diff --git a/unit_tests/__init__.py b/unit_tests/__init__.py index b7fe4e1..524cb9e 100644 --- a/unit_tests/__init__.py +++ b/unit_tests/__init__.py @@ -14,3 +14,4 @@ import sys sys.path.append('hooks') +sys.path.append('unit_tests') diff --git a/unit_tests/test_utils.py b/unit_tests/test_utils.py index 74b57c8..a5cf7f7 100644 --- a/unit_tests/test_utils.py +++ b/unit_tests/test_utils.py @@ -35,7 +35,7 @@ def load_config(): if not config: logging.error('Could not find config.yaml in any parent directory ' - 'of %s. ' % __file__) + 'of %s.'.format(__file__)) raise Exception return yaml.safe_load(open(config).read())['options'] @@ -47,7 +47,7 @@ def get_default_config(): """ default_config = {} config = load_config() - for k, v in config.iteritems(): + for k, v in config.items(): if 'default' in v: default_config[k] = v['default'] else: