当前位置: 首页>>代码示例>>Python>>正文


Python app.AppLoader类代码示例

本文整理汇总了Python中celery.loaders.app.AppLoader的典型用法代码示例。如果您正苦于以下问题:Python AppLoader类的具体用法?Python AppLoader怎么用?Python AppLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AppLoader类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_AppLoader

class test_AppLoader(Case):

    def setUp(self):
        self.app = app_or_default()
        self.loader = AppLoader(app=self.app)

    def test_config_from_envvar(self, key='CELERY_HARNESS_CFG1'):
        self.assertFalse(self.loader.config_from_envvar('HDSAJIHWIQHEWQU',
                                                        silent=True))
        with self.assertRaises(ImproperlyConfigured):
            self.loader.config_from_envvar('HDSAJIHWIQHEWQU', silent=False)
        os.environ[key] = __name__ + '.object_config'
        self.assertTrue(self.loader.config_from_envvar(key))
        self.assertEqual(self.loader.conf['FOO'], 1)
        self.assertEqual(self.loader.conf['BAR'], 2)

        os.environ[key] = 'unknown_asdwqe.asdwqewqe'
        with self.assertRaises(ImportError):
            self.loader.config_from_envvar(key, silent=False)
        self.assertFalse(self.loader.config_from_envvar(key, silent=True))

        os.environ[key] = __name__ + '.dict_config'
        self.assertTrue(self.loader.config_from_envvar(key))
        self.assertEqual(self.loader.conf['FOO'], 10)
        self.assertEqual(self.loader.conf['BAR'], 20)

    def test_on_worker_init(self):
        prev, self.app.conf.CELERY_IMPORTS = \
                self.app.conf.CELERY_IMPORTS, ('subprocess', )
        try:
            sys.modules.pop('subprocess', None)
            self.loader.init_worker()
            self.assertIn('subprocess', sys.modules)
        finally:
            self.app.conf.CELERY_IMPORTS = prev
开发者ID:qluo1,项目名称:cs253,代码行数:35,代码来源:test_loaders.py

示例2: test_AppLoader

class test_AppLoader(Case):
    def setUp(self):
        self.app = app_or_default()
        self.loader = AppLoader(app=self.app)

    def test_config_from_envvar(self, key="CELERY_HARNESS_CFG1"):
        self.assertFalse(self.loader.config_from_envvar("HDSAJIHWIQHEWQU", silent=True))
        with self.assertRaises(ImproperlyConfigured):
            self.loader.config_from_envvar("HDSAJIHWIQHEWQU", silent=False)
        os.environ[key] = __name__ + ".object_config"
        self.assertTrue(self.loader.config_from_envvar(key))
        self.assertEqual(self.loader.conf["FOO"], 1)
        self.assertEqual(self.loader.conf["BAR"], 2)

        os.environ[key] = "unknown_asdwqe.asdwqewqe"
        with self.assertRaises(ImportError):
            self.loader.config_from_envvar(key, silent=False)
        self.assertFalse(self.loader.config_from_envvar(key, silent=True))

        os.environ[key] = __name__ + ".dict_config"
        self.assertTrue(self.loader.config_from_envvar(key))
        self.assertEqual(self.loader.conf["FOO"], 10)
        self.assertEqual(self.loader.conf["BAR"], 20)

    def test_on_worker_init(self):
        self.loader.conf["CELERY_IMPORTS"] = ("subprocess",)
        sys.modules.pop("subprocess", None)
        self.loader.on_worker_init()
        self.assertIn("subprocess", sys.modules)
开发者ID:sunliwen,项目名称:celery,代码行数:29,代码来源:test_loaders.py

示例3: test_AppLoader

class test_AppLoader(AppCase):
    def setup(self):
        self.loader = AppLoader(app=self.app)

    def test_on_worker_init(self):
        self.app.conf.imports = ("subprocess",)
        sys.modules.pop("subprocess", None)
        self.loader.init_worker()
        self.assertIn("subprocess", sys.modules)
开发者ID:xuziyan001,项目名称:celery,代码行数:9,代码来源:test_loaders.py

示例4: setup

class test_AppLoader:

    def setup(self):
        self.loader = AppLoader(app=self.app)

    def test_on_worker_init(self):
        self.app.conf.imports = ('subprocess',)
        sys.modules.pop('subprocess', None)
        self.loader.init_worker()
        assert 'subprocess' in sys.modules
开发者ID:auvipy,项目名称:celery,代码行数:10,代码来源:test_loaders.py

示例5: test_AppLoader

class test_AppLoader(AppCase):

    def setup(self):
        self.loader = AppLoader(app=self.app)

    def test_on_worker_init(self):
        self.app.conf.CELERY_IMPORTS = ('subprocess', )
        sys.modules.pop('subprocess', None)
        self.loader.init_worker()
        self.assertIn('subprocess', sys.modules)
开发者ID:AnSavvides,项目名称:celery,代码行数:10,代码来源:test_loaders.py

示例6: test_AppLoader

class test_AppLoader(AppCase):
    def setup(self):
        self.loader = AppLoader(app=self.app)

    def test_on_worker_init(self):
        prev, self.app.conf.CELERY_IMPORTS = (self.app.conf.CELERY_IMPORTS, ("subprocess",))
        try:
            sys.modules.pop("subprocess", None)
            self.loader.init_worker()
            self.assertIn("subprocess", sys.modules)
        finally:
            self.app.conf.CELERY_IMPORTS = prev
开发者ID:peterbrook,项目名称:celery,代码行数:12,代码来源:test_loaders.py

示例7: test_AppLoader

class test_AppLoader(Case):

    def setUp(self):
        self.app = app_or_default()
        self.loader = AppLoader(app=self.app)

    def test_on_worker_init(self):
        prev, self.app.conf.CELERY_IMPORTS = (
            self.app.conf.CELERY_IMPORTS, ('subprocess', ))
        try:
            sys.modules.pop('subprocess', None)
            self.loader.init_worker()
            self.assertIn('subprocess', sys.modules)
        finally:
            self.app.conf.CELERY_IMPORTS = prev
开发者ID:dolfly,项目名称:celery,代码行数:15,代码来源:test_loaders.py

示例8: setUp

 def setUp(self):
     self.app = app_or_default()
     self.loader = AppLoader(app=self.app)
开发者ID:eldondev,项目名称:celery,代码行数:3,代码来源:test_loaders.py

示例9: setup

 def setup(self):
     self.loader = AppLoader(app=self.app)
开发者ID:huyidao625,项目名称:celery,代码行数:2,代码来源:test_loaders.py


注:本文中的celery.loaders.app.AppLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。