Removes the use of mutables as default args

Passing mutable objects as default args is a known Python pitfall.
We'd better avoid this. This commit changes mutable default args with
None, 'arg = [] if arg is None else arg'.

TrivialFix

Change-Id: I384b24e81543999a8b873e3223cd409ed799ffa0
This commit is contained in:
Edan David 2016-06-19 05:52:11 -04:00
parent da0a8aff88
commit 438c69af7c

@ -118,7 +118,8 @@ class TestIronicAPI(test_base.BaseTestCase):
status=status, method="post")
def get_json(self, path, expect_errors=False, headers=None,
extra_environ=None, q=[], path_prefix=PATH_PREFIX, **params):
extra_environ=None, q=None, path_prefix=PATH_PREFIX,
**params):
"""Sends simulated HTTP GET request to Pecan test app.
:param path: url path of target service
@ -137,6 +138,7 @@ class TestIronicAPI(test_base.BaseTestCase):
'q.value': [],
'q.op': [],
}
q = [] if q is None else q
for query in q:
for name in ['field', 'op', 'value']:
query_params['q.%s' % name].append(query.get(name, ''))