Port from Python2 to Python3

Switch to stestr

Change-Id: I97b333785d631f56e70eafe568842e8de8e207a9
This commit is contained in:
Sawan Choudhary 2020-06-12 00:20:43 -07:00
parent 748e85199f
commit 030ca32360
13 changed files with 29 additions and 26 deletions

2
.gitignore vendored

@ -25,7 +25,7 @@ pip-log.txt
.coverage
.tox
nosetests.xml
.testrepository
.stestr/
.venv
# Translations

3
.stestr.conf Normal file

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${OS_TEST_PATH:-./cloudpulseclient/tests/}
top_dir=./

@ -2,6 +2,8 @@
check:
jobs:
- openstack-tox-pep8
- openstack-tox-py36
gate:
jobs:
- openstack-tox-pep8
- openstack-tox-py36

@ -79,7 +79,7 @@ class HTTPClient(object):
def log_curl_request(self, method, url, kwargs):
curl = ['curl -i -X %s' % method]
for (key, value) in kwargs['headers'].items():
for (key, value) in list(kwargs['headers'].items()):
header = '-H \'%s: %s\'' % (key, value)
curl.append(header)
@ -343,9 +343,9 @@ class ResponseBodyIterator(object):
def __iter__(self):
while True:
yield self.next()
yield next(self)
def next(self):
def __next__(self):
chunk = self.resp.read(CHUNKSIZE)
if chunk:
return chunk

@ -258,7 +258,7 @@ class ManagerWithFind(BaseManager):
the Python side.
"""
found = []
searches = kwargs.items()
searches = list(kwargs.items())
for obj in self.list():
try:
@ -423,7 +423,7 @@ class Extension(HookableMixin):
def _parse_extension_module(self):
self.manager_class = None
for attr_name, attr_value in self.module.__dict__.items():
for attr_name, attr_value in list(self.module.__dict__.items()):
if attr_name in self.SUPPORTED_HOOKS:
self.add_hook(attr_name, attr_value)
else:
@ -460,7 +460,7 @@ class Resource(object):
def __repr__(self):
reprkeys = sorted(k
for k in self.__dict__.keys()
for k in list(self.__dict__.keys())
if k[0] != '_' and k != 'manager')
info = ", ".join("%s=%s" % (k, getattr(self, k)) for k in reprkeys)
return "<%s %s>" % (self.__class__.__name__, info)

@ -382,7 +382,7 @@ class BaseClient(object):
"Must be one of: %(version_map)s") % {
'api_name': api_name,
'version': version,
'version_map': ', '.join(version_map.keys())}
'version_map': ', '.join(list(version_map.keys()))}
raise exceptions.UnsupportedVersion(msg)
return importutils.import_class(client_path)

@ -16,7 +16,7 @@
# W0621: Redefining name %s from outer scope
# pylint: disable=W0603,W0621
from __future__ import print_function
import getpass
import inspect

@ -22,7 +22,7 @@
Command-line interface to the OpenStack Cloudpulse API.
"""
from __future__ import print_function
import argparse
import getpass
import logging
@ -561,9 +561,9 @@ class OpenStackCloudPulseShell(object):
"""
commands = set()
options = set()
for sc_str, sc in self.subcommands.items():
for sc_str, sc in list(self.subcommands.items()):
commands.add(sc_str)
for option in sc._optionals._option_string_actions.keys():
for option in list(sc._optionals._option_string_actions.keys()):
options.add(option)
commands.remove('bash-completion')
@ -595,8 +595,8 @@ class OpenStackHelpFormatter(argparse.HelpFormatter):
def main():
try:
OpenStackCloudPulseShell().main(map(encodeutils.safe_decode,
sys.argv[1:]))
OpenStackCloudPulseShell().main(list(map(encodeutils.safe_decode,
sys.argv[1:])))
except Exception as e:
logger.debug(e, exc_info=1)

@ -57,7 +57,7 @@ class HealthCheckManager(base.Manager):
def create(self, **kwargs):
new = {}
for (key, value) in kwargs.items():
for (key, value) in list(kwargs.items()):
new[key] = value
return self._create(self._path(), new)

@ -36,8 +36,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'python-cloudpulseclient'
copyright = u'2013, OpenStack Foundation'
project = 'python-cloudpulseclient'
copyright = '2013, OpenStack Foundation'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
@ -66,8 +66,8 @@ htmlhelp_basename = '%sdoc' % project
latex_documents = [
('index',
'%s.tex' % project,
u'%s Documentation' % project,
u'OpenStack Foundation', 'manual'),
'%s Documentation' % project,
'OpenStack Foundation', 'manual'),
]
# Example configuration for intersphinx: refer to the Python standard library.

@ -13,13 +13,9 @@ classifier =
License :: OSI Approved :: Apache Software License
Operating System :: POSIX :: Linux
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
[files]
packages =

@ -9,6 +9,6 @@ python-subunit>=0.0.18
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
oslosphinx>=2.5.0 # Apache-2.0
oslotest>=1.10.0 # Apache-2.0
testrepository>=0.0.18
stestr>=2.0.0
testscenarios>=0.4
testtools>=1.4.0

@ -1,5 +1,5 @@
[tox]
minversion = 2.0
minversion = 3.1.1
envlist = py36,pep8
skipsdist = True
@ -17,11 +17,13 @@ deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
passenv = TEMPEST_* OS_TEST_*
whitelist_externals = find, stestr
commands =
find . -type f -name "*.py[c|o]" -delete
stestr run {posargs}
[testenv:pep8]
whitelist_externals = bash
commands =
bash tools/flake8wrap.sh {posargs}