Skip to content

Commit

Permalink
Remove custom item retrieval in the params object
Browse files Browse the repository at this point in the history
Not only does this hide a proper stack trace of where the missing
parameter was detected but it also makes it impossible to use
other useful methods like pop() with a default and so on, all
because of the unnecessary custom ParamNotFound error which is
never caught in an exception clause at the abc collection on
a higher level.

Signed-off-by: Plamen Dimitrov <[email protected]>
  • Loading branch information
pevogam committed Jan 17, 2019
1 parent eb5a180 commit 6024638
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions virttest/utils_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,6 @@ class Params(IterableUserDict):
"""
lock = Lock()

def __getitem__(self, key):
""" overrides the error messages of missing params[$key] """
try:
return IterableUserDict.__getitem__(self, key)
except KeyError:
raise ParamNotFound("Mandatory parameter '%s' is missing. "
"Check your cfg files for typos/mistakes" %
key)

def get(self, key, default=None):
""" overrides the behavior to catch ParamNotFound error"""
try:
return self[key]
except ParamNotFound:
return default

def setdefault(self, key, failobj=None):
if key not in self:
self[key] = failobj
Expand Down

0 comments on commit 6024638

Please sign in to comment.