Merge "its a bad idea to use mutable default parameter"

This commit is contained in:
Jenkins 2017-04-25 13:51:21 +00:00 committed by Gerrit Code Review
commit 2471da689c
2 changed files with 9 additions and 4 deletions

View File

@ -57,7 +57,7 @@ class ReScheduler(object):
times=-1, times=-1,
ttl=None, ttl=None,
fault_callback=None, fault_callback=None,
fault_callback_kwargs={}): fault_callback_kwargs=None):
"""Schedule a new task """Schedule a new task
:param func: function to run :param func: function to run
@ -86,6 +86,8 @@ class ReScheduler(object):
:return: None :return: None
""" """
if fault_callback_kwargs is None:
fault_callback_kwargs = {}
if times == 0: if times == 0:
return None return None
@ -140,8 +142,10 @@ class ReScheduler(object):
times=-1, times=-1,
ttl=None, ttl=None,
fault_callback=None, fault_callback=None,
fault_callback_kwargs={}): fault_callback_kwargs=None):
if fault_callback_kwargs is None:
fault_callback_kwargs = {}
self.scheduler = scheduler self.scheduler = scheduler
self.func = func self.func = func
self.args = args self.args = args

View File

@ -184,9 +184,10 @@ class AodhDriverTest(base.BaseTest):
def _extract_alarm_data(self, def _extract_alarm_data(self,
state="ok", state="ok",
type="event", type="event",
rule={"query": [], rule=None):
"event_type": "*"}):
if rule is None:
rule = {"query": [], "event_type": "*"}
return {AodhProps.DESCRIPTION: "test", return {AodhProps.DESCRIPTION: "test",
AodhProps.TIMESTAMP: "2016-11-09T01:39:13.839584", AodhProps.TIMESTAMP: "2016-11-09T01:39:13.839584",
AodhProps.ENABLED: True, AodhProps.ENABLED: True,