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:
parent
1ac00d4a70
commit
b42d1415d8
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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']
|
||||
|
@ -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',
|
||||
|
Loading…
x
Reference in New Issue
Block a user