1 # Copyright (c) 2018 Intel Corporation
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 from yardstick.common import utils
21 class ImportModulesFromPackageTestCase(unittest.TestCase):
23 def test_import_package(self):
24 module_name = 'yardstick.tests.functional.common.fake_module'
25 library_name = 'fake_library'
26 class_name = 'FakeClassToBeImported'
27 self.assertNotIn(module_name, sys.modules)
29 utils.import_modules_from_package(module_name)
30 self.assertIn(module_name, sys.modules)
31 module_obj = sys.modules[module_name]
32 library_obj = getattr(module_obj, library_name)
33 class_obj = getattr(library_obj, class_name)
34 self.assertEqual(class_name, class_obj().__class__.__name__)