def test_subsequent_calls_for_same_class_name_under_different_paths_return_different_class_names(self): parent_path = os.path.dirname(os.path.realpath(__file__)) response1 = get_classes_from_module(os.path.join(parent_path, 'res_test_robot_session_server', 'a', 'LibClass.py'), [], []) response2 = get_classes_from_module(os.path.join(parent_path, 'res_test_robot_session_server', 'b', 'LibClass.py'), [], []) self.assertNotEqual(response1, response2)
def test_if_sys_path_is_not_extended_after_retrieving_classes_from_python_module(self): parent_path = os.path.dirname(os.path.realpath(__file__)) python_paths = [os.path.join(parent_path, 'res_test_robot_session_server', 'a')] class_paths = [os.path.join(parent_path, 'res_test_robot_session_server', 'b')] old_sys_path = sorted(sys.path) get_classes_from_module(os.path.join(parent_path, 'res_test_robot_session_server', 'a', 'LibClass.py'), python_paths, class_paths) self.assertEqual(old_sys_path, sorted(sys.path))
def test_retrieving_classes_from_python_module_in_jar(self): parent_path = os.path.dirname(os.path.realpath(__file__)) module_location = os.path.join(parent_path, 'res_test_robot_session_server', 'module', 'compressed.jar') classes = get_classes_from_module(module_location, None, [], []) self.assertEqual( classes, { 'result': ['compressed.mod_compressed_1', 'compressed.mod_compressed_2'], 'exception': None })
def test_retrieving_classes_from_python_module_with_init(self): parent_path = os.path.dirname(os.path.realpath(__file__)) module_location = os.path.join(parent_path, 'res_test_robot_session_server', 'module', '__init__.py') response = get_classes_from_module(module_location, None, [], []) self.assertEqual( response, { 'result': [ 'module', 'mod_1', 'mod_2', 'module.module', 'module.mod_1', 'module.mod_2' ], 'exception': None })
def test_retrieving_classes_from_python_module_with_several_classes(self): parent_path = os.path.dirname(os.path.realpath(__file__)) module_location = os.path.join(parent_path, 'res_test_robot_session_server', 'module', 'mod_2.py') classes = get_classes_from_module(module_location, None, [], []) self.assertEqual( classes, { 'result': [ 'mod_2', 'mod_2.mod_2', 'mod_2.other_mod_2', 'module.mod_2', 'module.mod_2.mod_2', 'module.mod_2.other_mod_2' ], 'exception': None })