Use None instead of mutables in method params default values

Mutables in the method params defaults might cause errors and
that's why it's anti-pattern in most of the cases and should be
removed.

Change-Id: Ib1498e68ab9cc770b237a324b733c85b4a5c6839
This commit is contained in:
Lena Novokshonova 2014-09-19 11:56:56 +04:00
parent 1ac00d4a70
commit b42d1415d8
4 changed files with 16 additions and 5 deletions

View File

@ -41,8 +41,9 @@ def make_resource_metadata(res_metadata=None, host_url=None):
def make_sample_from_host(host_url, name, sample_type, unit, volume,
project_id=None, user_id=None, resource_id=None,
res_metadata=None, extra={}):
res_metadata=None, extra=None):
extra = extra or {}
resource_metadata = make_resource_metadata(res_metadata, host_url)
resource_metadata.update(extra)

View File

@ -103,8 +103,10 @@ NM_GET_DEVICE_ID_TEMPLATE['Last_digit_firmware_build_number'] = 1
NM_GET_DEVICE_ID_TEMPLATE['Image_flags'] = 1
def _hex(list=[]):
def _hex(list=None):
"""Format the return value in list into hex."""
list = list or []
if list:
list.reverse()
return int(''.join(list), 16)

View File

@ -112,11 +112,14 @@ def _parse_output(output, template):
return ret
def execute_ipmi_cmd(template={}):
def execute_ipmi_cmd(template=None):
"""Decorator for the execution of IPMI command.
It parses the output of IPMI command into dictionary.
"""
template = template or []
def _execute_ipmi_cmd(f):
def _execute(self, **kwargs):
args = ['ipmitool']

View File

@ -628,9 +628,14 @@ class TestAlarms(v2.FunctionalTest,
'not valid for this resource',
resp.json['error_message']['faultstring'])
def _do_post_alarm_invalid_action(self, ok_actions=[], alarm_actions=[],
insufficient_data_actions=[],
def _do_post_alarm_invalid_action(self, ok_actions=None,
alarm_actions=None,
insufficient_data_actions=None,
error_message=None):
ok_actions = ok_actions or []
alarm_actions = alarm_actions or []
insufficient_data_actions = insufficient_data_actions or []
json = {
'enabled': False,
'name': 'added_alarm',