diff --git a/avocado/test.py b/avocado/test.py index 8e2e232dd3756f5f317421cd18eccf6bbe4c3be4..606ab90aedf00167347db68cf8da63a328d7d2f4 100644 --- a/avocado/test.py +++ b/avocado/test.py @@ -144,7 +144,6 @@ class Test(unittest.TestCase): # Apply what comes from the params dict for key in sorted(self.params.keys()): self.log.debug(' %s = %s', key, self.params.get(key)) - setattr(self.params, key, self.params.get(key)) self.log.debug('') # Apply what comes from the default_params dict @@ -157,7 +156,7 @@ class Test(unittest.TestCase): self.log.debug('') # If there's a timeout set, log a timeout reminder - if hasattr(self.params, 'timeout'): + if self.params.timeout: self.log.info('Test timeout set. Will wait %.2f s for ' 'PID %s to end', float(self.params.timeout), os.getpid()) @@ -205,7 +204,6 @@ class Test(unittest.TestCase): self.params[key] except Exception: self.params[key] = default - setattr(self.params, key, default) def get_deps_path(self, basename): """ diff --git a/avocado/utils/params.py b/avocado/utils/params.py index 52cb6b5066a142dabc5f55e97e7d28d1ca92454b..8aa8007dc15b60c54e61392e6e33ed8522d76c71 100644 --- a/avocado/utils/params.py +++ b/avocado/utils/params.py @@ -25,7 +25,10 @@ class Params(UserDict.IterableUserDict): try: value = UserDict.IterableUserDict.__getitem__(self, key) vtype = UserDict.IterableUserDict.get(self, "%s_type" % key) - return settings.convert_value_type(value, vtype) + if vtype is not None: + return settings.convert_value_type(value, vtype) + else: + return value except KeyError: raise ParamNotFound("Mandatory parameter '%s' is missing. " "Check your cfg files for typos/mistakes" % @@ -35,6 +38,15 @@ class Params(UserDict.IterableUserDict): "convert to %s: %s" % (key, value, vtype, details)) + def __getattr__(self, attr): + try: + return UserDict.IterableUserDict.__getattr__(self, attr) + except AttributeError: + try: + return self.__getitem__(attr) + except ParamNotFound: + return None + def objects(self, key): """ Return the names of objects defined using a given key. @@ -59,7 +71,7 @@ class Params(UserDict.IterableUserDict): """ suffix = "_" + obj_name self.lock.acquire() - new_dict = self.copy() + new_dict = self.data.copy() self.lock.release() for key in new_dict.keys(): if key.endswith(suffix):