diff --git a/pyext/swsscommon.i b/pyext/swsscommon.i index 77cdf364..c06badb0 100644 --- a/pyext/swsscommon.i +++ b/pyext/swsscommon.i @@ -36,11 +36,11 @@ %template(VectorString) std::vector; %pythoncode %{ - def _FieldValueMap__get(self, key, defval): + def _FieldValueMap__get(self, key, default=None): if key in self: return self[key] else: - return defval + return default def _FieldValueMap__update(self, *args, **kwargs): other = dict(*args, **kwargs) diff --git a/tests/test_redis_ut.py b/tests/test_redis_ut.py index 2001af4c..cc934e47 100644 --- a/tests/test_redis_ut.py +++ b/tests/test_redis_ut.py @@ -147,6 +147,8 @@ def test_DBInterface(): assert fvs["field1"] == "value2" # Test dict.get() + assert fvs.get("field1") == "value2" + assert fvs.get("field1_noexisting") == None assert fvs.get("field1", "default") == "value2" assert fvs.get("nonfield", "default") == "default"