From 97004997c00dac2e0dcfeef303af4701e78bb909 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Wed, 21 Jun 2017 19:25:22 -0700 Subject: constants: cache YAML config values don't reparse the yardstick.yaml file each time we lookup an option. Since it is global data, just cache it in a global var Use pkg_resources.resource_filename to lookup the path of yardstick tests, intsead of using __file__ pkg_resources is slightly more proper than __file__ at least for packages Change-Id: I05d9748390a37bd45c53013fc084d23069ab7c51 Signed-off-by: Ross Brattain --- tests/unit/common/test_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/unit/common/test_utils.py b/tests/unit/common/test_utils.py index 53b56523e..094ab2b19 100644 --- a/tests/unit/common/test_utils.py +++ b/tests/unit/common/test_utils.py @@ -21,6 +21,7 @@ import mock from six.moves import configparser from yardstick.common import utils +from yardstick.common import constants class IterSubclassesTestCase(unittest.TestCase): @@ -99,7 +100,7 @@ class GetParaFromYaml(unittest.TestCase): get_env.return_value = self._get_file_abspath(file_path) args = 'releng.file' default = 'hello' - self.assertTrue(utils.get_param(args, default), default) + self.assertTrue(constants.get_param(args, default), default) @mock.patch('yardstick.common.utils.os.environ.get') def test_get_param_para_exists(self, get_env): @@ -107,7 +108,7 @@ class GetParaFromYaml(unittest.TestCase): get_env.return_value = self._get_file_abspath(file_path) args = 'releng.dir' para = '/home/opnfv/repos/releng' - self.assertEqual(para, utils.get_param(args)) + self.assertEqual(para, constants.get_param(args)) def _get_file_abspath(self, filename): curr_path = os.path.dirname(os.path.abspath(__file__)) -- cgit 1.2.3-korg