Fix N529 Method's default argument should not be mutable

See:
[1] http://python-guide-pt-br.readthedocs.io/en/latest/writing/gotchas/#mutable-default-arguments

Partial-Bug: #1704691

Change-Id: Ibd202f1970a6138299648040f635278ba9d9d71b
This commit is contained in:
Ngo Quoc Cuong 2017-07-10 02:55:20 -04:00
parent 9c5e45fa56
commit f4fbbc1770
3 changed files with 15 additions and 5 deletions

View File

@ -23,7 +23,9 @@ from cinderclient import exceptions as cinder_exception
from novaclient import exceptions as nova_exception
def mock_list_with_attach_to_this(cls, search_opts={}):
def mock_list_with_attach_to_this(cls, search_opts=None):
if search_opts is None:
search_opts = {}
attachments = [{u'server_id': u'123',
u'attachment_id': u'123',
u'attached_at': u'2016-05-20T09:19:57.000000',
@ -34,7 +36,9 @@ def mock_list_with_attach_to_this(cls, search_opts={}):
attachments=attachments)]
def mock_list_with_attach_to_other(cls, search_opts={}):
def mock_list_with_attach_to_other(cls, search_opts=None):
if search_opts is None:
search_opts = {}
attachments = [{u'server_id': u'1234',
u'attachment_id': u'123',
u'attached_at': u'2016-05-20T09:19:57.000000',

View File

@ -38,7 +38,9 @@ def mock_get_connector_properties(multipath=False, enforce_multipath=False):
return props
def mock_list_with_attach_to_this(cls, search_opts={}):
def mock_list_with_attach_to_this(cls, search_opts=None):
if search_opts is None:
search_opts = {}
attachments = [{u'server_id': u'123',
u'attachment_id': u'123',
u'attached_at': u'2016-05-20T09:19:57.000000',
@ -49,7 +51,9 @@ def mock_list_with_attach_to_this(cls, search_opts={}):
attachments=attachments)]
def mock_list_with_attach_to_other(cls, search_opts={}):
def mock_list_with_attach_to_other(cls, search_opts=None):
if search_opts is None:
search_opts = {}
attachments = [{u'server_id': u'123',
u'attachment_id': u'123',
u'attached_at': u'2016-05-20T09:19:57.000000',

View File

@ -20,7 +20,9 @@ class FakeCinderClient(object):
def get(self, volume_id):
return fake_object.FakeCinderVolume(id=volume_id)
def list(self, search_opts={}):
def list(self, search_opts=None):
if search_opts is None:
search_opts = {}
return [fake_object.FakeCinderVolume(name='fake-vol1')]
def create(self, *args, **kwargs):