diff --git a/tacker/api/api_common.py b/tacker/api/api_common.py index 55141a2cb..980aff0a5 100644 --- a/tacker/api/api_common.py +++ b/tacker/api/api_common.py @@ -26,7 +26,7 @@ from tacker.openstack.common import log as logging LOG = logging.getLogger(__name__) -def get_filters(request, attr_info, skips=[]): +def get_filters(request, attr_info, skips=None): """Extracts the filters from the request string. Returns a dict of lists for the filters: @@ -35,6 +35,8 @@ def get_filters(request, attr_info, skips=[]): {'check': [u'a', u'b'], 'name': [u'Bob']} """ res = {} + if skips is None: + skips = [] for key, values in request.GET.dict_of_lists().iteritems(): if key in skips: continue diff --git a/tacker/openstack/common/db/exception.py b/tacker/openstack/common/db/exception.py index 436cc8626..409530cf9 100644 --- a/tacker/openstack/common/db/exception.py +++ b/tacker/openstack/common/db/exception.py @@ -30,8 +30,8 @@ class DBError(Exception): class DBDuplicateEntry(DBError): """Wraps an implementation specific exception.""" - def __init__(self, columns=[], inner_exception=None): - self.columns = columns + def __init__(self, columns=None, inner_exception=None): + self.columns = columns if columns else [] super(DBDuplicateEntry, self).__init__(inner_exception) diff --git a/tacker/tests/unit/extension_stubs.py b/tacker/tests/unit/extension_stubs.py index cfec4dfd0..5c11fe024 100644 --- a/tacker/tests/unit/extension_stubs.py +++ b/tacker/tests/unit/extension_stubs.py @@ -43,8 +43,9 @@ class StubExtension(object): class StubPlugin(object): - def __init__(self, supported_extensions=[]): - self.supported_extension_aliases = supported_extensions + def __init__(self, supported_extensions=None): + self.supported_extension_aliases = supported_extensions \ + if supported_extensions else [] class ExtensionExpectingPluginInterface(StubExtension): diff --git a/tacker/tests/unit/test_api_v2.py b/tacker/tests/unit/test_api_v2.py index d32a1e7d6..a9fcd0ed8 100644 --- a/tacker/tests/unit/test_api_v2.py +++ b/tacker/tests/unit/test_api_v2.py @@ -134,9 +134,11 @@ class APIv2TestCase(APIv2TestBase): fields.extend(policy_attrs) return fields - def _get_collection_kwargs(self, skipargs=[], **kwargs): + def _get_collection_kwargs(self, skipargs=None, **kwargs): args_list = ['filters', 'fields', 'sorts', 'limit', 'marker', 'page_reverse'] + if skipargs is None: + skipargs = [] args_dict = dict((arg, mock.ANY) for arg in set(args_list) - set(skipargs)) args_dict.update(kwargs) diff --git a/tacker/vm/infra_drivers/heat/heat.py b/tacker/vm/infra_drivers/heat/heat.py index a0a35e2ea..09eac54a5 100644 --- a/tacker/vm/infra_drivers/heat/heat.py +++ b/tacker/vm/infra_drivers/heat/heat.py @@ -160,8 +160,10 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver): } } - def handle_port_creation(network_param, ip_list=[], + def handle_port_creation(network_param, ip_list=None, mgmt_port=False): + if ip_list is None: + ip_list = [] port = '%s-%s-port' % (vdu_id, network_param['network']) port_dict = make_port_dict() if mgmt_port: