Exemplo n.º 1
0
    def test_if_python_module_path_is_returned(self):
        parent_path = os.path.dirname(os.path.realpath(__file__))
        module_path = os.path.join(parent_path, 'res_test_red_modules')

        import importlib
        importlib.import_module('res_test_red_modules')

        result = get_module_path('res_test_red_modules')

        self.assertEqual(result, module_path)
Exemplo n.º 2
0
def get_module_path(module_name, python_paths, class_paths):
    import red_modules
    import platform
    from robot import pythonpathsetter

    __extend_classpath(class_paths)

    for path in python_paths + class_paths:
        pythonpathsetter.add_path(path)
    module_path = red_modules.get_module_path(module_name)
    for path in python_paths + class_paths:
        pythonpathsetter.remove_path(path)
    return module_path
Exemplo n.º 3
0
    def test_if_jar_module_path_is_returned_for_python_module(self):
        import platform
        if 'Jython' in platform.python_implementation():
            parent_path = os.path.dirname(os.path.realpath(__file__))
            module_path = os.path.join(parent_path, 'res_test_red_modules', 'SamplePythonLib.jar')

            from classpath_updater import ClassPathUpdater
            cp_updater = ClassPathUpdater()
            cp_updater.add_file(module_path)
            result = get_module_path('ExamplePythonLibrary')

            from java.io import File
            self.assertEqual(File(result).getAbsolutePath(), File(module_path).getAbsolutePath())
Exemplo n.º 4
0
def get_module_path(module_name, python_paths, class_paths):
    import red_modules
    import platform
    from robot import pythonpathsetter

    __extend_classpath(class_paths)
    
    for path in python_paths + class_paths:
        pythonpathsetter.add_path(path)    
    module_path = red_modules.get_module_path(module_name)
    for path in python_paths + class_paths:
        pythonpathsetter.remove_path(path)    
    return module_path
Exemplo n.º 5
0
 def test_if_exception_is_raised_when_module_path_cannot_be_found(self):
     with self.assertRaises(ImportError):
         get_module_path('UnknownModuleName')
Exemplo n.º 6
0
def get_module_path(module_name, python_paths, class_paths):
    import red_modules
    __extend_paths(python_paths, class_paths)
    return red_modules.get_module_path(module_name)
Exemplo n.º 7
0
 def to_call():
     import red_modules
     return red_modules.get_module_path(module_name)
Exemplo n.º 8
0
    def test_if_module_path_is_returned(self):
        result = get_module_path('robot.libraries.BuiltIn')

        self.assertTrue(len(result) > 0)