Improve the way of setting values in CONST
authorLinda Wang <wangwulin@huawei.com>
Tue, 19 Dec 2017 09:23:04 +0000 (09:23 +0000)
committerCédric Ollivier <cedric.ollivier@orange.com>
Tue, 13 Feb 2018 06:44:30 +0000 (07:44 +0100)
Use setattr instead of internal method (__setattr__).
It must be completed by patches fixing [1] [2] and [3].

[1] https://jira.opnfv.org/browse/FUNCTEST-930
[2] https://jira.opnfv.org/browse/FUNCTEST-931
[3] https://jira.opnfv.org/browse/FUNCTEST-932

Change-Id: I9558f33f5ed4559b6031d75951d5637c0c0ef8cb
Signed-off-by: Linda Wang <wangwulin@huawei.com>
functest/opnfv_tests/sdn/odl/odl.py
functest/utils/config.py
functest/utils/constants.py

index 25cc758..6af49ff 100644 (file)
@@ -38,7 +38,7 @@ __author__ = "Cedric Ollivier <cedric.ollivier@orange.com>"
 class ODLTests(robotframework.RobotFramework):
     """ODL test runner."""
 
-    odl_test_repo = constants.CONST.__getattribute__('dir_repo_odl_test')
+    odl_test_repo = getattr(constants.CONST, 'dir_repo_odl_test')
     neutron_suite_dir = os.path.join(
         odl_test_repo, "csit/suites/openstack/neutron")
     basic_suite_dir = os.path.join(
@@ -51,7 +51,7 @@ class ODLTests(robotframework.RobotFramework):
     def __init__(self, **kwargs):
         super(ODLTests, self).__init__(**kwargs)
         self.res_dir = os.path.join(
-            constants.CONST.__getattribute__('dir_results'), 'odl')
+            getattr(constants.CONST, 'dir_results'), 'odl')
         self.xml_file = os.path.join(self.res_dir, 'output.xml')
 
     @classmethod
index 050f12a..c569856 100644 (file)
@@ -45,7 +45,7 @@ class Config(object):
         for param_n, param_v in six.iteritems(left_parametes):
             attr_further = self._get_attr_further(attr_now, param_n)
             if attr_further:
-                self.__setattr__(attr_further, param_v)
+                setattr(self, attr_further, param_v)
             if isinstance(param_v, dict):
                 self._parse(attr_further, param_v)
 
index cb3ea78..c19e0fc 100644 (file)
@@ -12,9 +12,9 @@ class Constants(object):  # pylint: disable=too-few-public-methods
 
     def __init__(self):
         for attr_n, attr_v in six.iteritems(config.CONF.__dict__):
-            self.__setattr__(attr_n, attr_v)
+            setattr(self, attr_n, attr_v)
         for env_n, env_v in six.iteritems(env.ENV.__dict__):
-            self.__setattr__(env_n, env_v)
+            setattr(self, env_n, env_v)
 
 
 CONST = Constants()