示例#1
0
    def test_import_by_path(self):
        with self.assertRaises(ImportError):
            import_by_path('len')

        with self.assertRaises(ImportError):
            import_by_path('uwsgi_tasks.tests.unknown_function')

        main = __import__('__main__')
        main.local_function = local_function

        self.assertTrue(local_function is import_by_path('local_function'))

        self.assertTrue(local_function is import_by_path(
            'uwsgi_tasks.tests.local_function'))
        self.assertTrue(
            len is import_by_path('{}.len'.format(self.builtin_module)))
示例#2
0
    def test_import_by_path(self):
        with self.assertRaises(ImportError):
            import_by_path('len')

        with self.assertRaises(ImportError):
            import_by_path('uwsgi_tasks.tests.unknown_function')

        main = __import__('__main__')
        main.local_function = local_function

        self.assertTrue(local_function is import_by_path('local_function'))

        self.assertTrue(
            local_function is import_by_path('uwsgi_tasks.tests.local_function')
        )

        self.assertTrue(len is import_by_path('__builtin__.len'))
示例#3
0
def load_function(func_name):
    func = getattr(saved_tasks, func_name, None)
    if func:
        return func
    return import_by_path(func_name)
示例#4
0
def load_function(func_name):
    func = getattr(saved_tasks, func_name, None)
    if func:
        return func
    return import_by_path(func_name)