Replacing six.iteritems() with .items()
We should avoid using six.iteritems to achieve iterators. We can use dict.items instead, as it will return iterators in PY3 as well. And dict.items/keys will be more readable. For more information, please refer to [1][2]. [1] https://wiki.openstack.org/wiki/Python3#Common_patterns [2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html Change-Id: Ib1a5c6c4770d052d3e1c87eda037126442cb732c
This commit is contained in:
parent
8d3f1cf375
commit
067c76509f
@ -38,7 +38,7 @@ def construct_new_test_function(original_func, name, build_params):
|
||||
argdefs=six.get_function_defaults(original_func)
|
||||
)
|
||||
|
||||
for key, val in six.iteritems(original_func.__dict__):
|
||||
for key, val in original_func.__dict__.items():
|
||||
if key != 'build_data':
|
||||
new_func.__dict__[key] = val
|
||||
|
||||
@ -61,7 +61,7 @@ def process_parameterized_function(name, func_obj, build_data):
|
||||
to_remove = []
|
||||
to_add = []
|
||||
|
||||
for subtest_name, params in six.iteritems(build_data):
|
||||
for subtest_name, params in build_data.items():
|
||||
# Build new test function
|
||||
func_name = '{0}_{1}'.format(name, subtest_name)
|
||||
new_func = construct_new_test_function(func_obj, func_name, params)
|
||||
@ -83,7 +83,7 @@ def parameterized_test_case(cls):
|
||||
"""
|
||||
tests_to_remove = []
|
||||
tests_to_add = []
|
||||
for key, val in six.iteritems(vars(cls)):
|
||||
for key, val in vars(cls).items():
|
||||
# Only process tests with build data on them
|
||||
if key.startswith('test_') and val.__dict__.get('build_data'):
|
||||
to_remove, to_add = process_parameterized_function(
|
||||
|
Loading…
Reference in New Issue
Block a user