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


Python DynamicHtml.getModule方法代码示例

本文整理汇总了Python中meresco.html.DynamicHtml.getModule方法的典型用法代码示例。如果您正苦于以下问题:Python DynamicHtml.getModule方法的具体用法?Python DynamicHtml.getModule怎么用?Python DynamicHtml.getModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meresco.html.DynamicHtml的用法示例。


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

示例1: testShouldExposeLoadedModulesForTestingPurposes

# 需要导入模块: from meresco.html import DynamicHtml [as 别名]
# 或者: from meresco.html.DynamicHtml import getModule [as 别名]
    def testShouldExposeLoadedModulesForTestingPurposes(self):
        open(self.tempdir + '/one.sf', 'w').write(r"""
attr = 'attr'
def sync():
    return 'aye'
def asyncReturn():
    raise StopIteration('aye')
    yield
def observableDownward():
    yield observable.all.something('arg', kw='kw')
def main(*args, **kwargs):
    yield "Hoi"
""")
        open(self.tempdir + '/two.sf', 'w').write(r"""

import one

def parameterized(arg, *args, **kwargs):
    return arg, args, kwargs

def main(*args, **kwargs):
    yield one.observableDownward()
""")
        reactor = Reactor()
        d = DynamicHtml([self.tempdir], reactor=reactor)
        t1 = CallTrace('t1')
        t2 = CallTrace('t2')
        d.addObserver(t1)
        d.addObserver(t2)
        one = d.getModule(name='one')
        two = d.getModule('two')

        self.assertEquals(None, d.getModule('does-not-exist'))

        self.assertEquals('attr', one.attr)
        self.assertEquals('aye', one.sync())
        try:
            g = compose(one.asyncReturn())
            g.next()
        except StopIteration, e:
            self.assertEquals(('aye',), e.args)
开发者ID:seecr,项目名称:meresco-html,代码行数:43,代码来源:dynamichtmltest.py

示例2: test

# 需要导入模块: from meresco.html import DynamicHtml [as 别名]
# 或者: from meresco.html.DynamicHtml import getModule [as 别名]
        def test():
            additionalGlobals = {
                'util_reloaded_id': howOften("util-reloaded"),
                'using_util_reloaded_id': howOften("using-util-reloaded"),
                'orphan_reloaded_id': howOften("orphan-reloaded"),
            }
            d = DynamicHtml([self.tempdir], reactor=reactor(), additionalGlobals=additionalGlobals)

            # Allow cleanup of directoryWatcherReadFD (whitebox)
            _reactorFdsKeys = reactor()._fds.keys()
            self.assertEquals(1, len(_reactorFdsKeys))
            directoryWatcherReadFD = _reactorFdsKeys[0]

            yield zleep(0.01)   # Allow DirectoryWatcher some reactor time

            # Initialized once
            util, orphan, using_util = d.getModule('util'), d.getModule('orphan'), d.getModule('using-util')
            self.assertEquals(
                ['util-reloaded:1',
                 'orphan-reloaded:1',
                 'using-util-reloaded:1'],
                [util.reloaded, orphan.reloaded, using_util.reloaded])
            self.assertEquals('using-util-reloaded:1 - util-reloaded:1', using_util.using())

            # Touch & **all** reloaded
            with open(fp_util, 'w') as f:
                f.write(util_contents)
            yield zleep(0.02)   # Allow DirectoryWatcher some reactor time

            util, orphan, using_util = d.getModule('util'), d.getModule('orphan'), d.getModule('using-util')
            self.assertEquals(
                ['util-reloaded:2',
                 'orphan-reloaded:2',
                 'using-util-reloaded:2'],
                [util.reloaded, orphan.reloaded, using_util.reloaded])
            self.assertEquals('using-util-reloaded:2 - util-reloaded:2', using_util.using())

            # Remove file - nothing happens
            remove(fp_orphan)
            yield zleep(0.02)   # Allow DirectoryWatcher some reactor time

            util, orphan, using_util = d.getModule('util'), d.getModule('orphan'), d.getModule('using-util')
            self.assertNotEqual(None, orphan)
            self.assertEquals(
                ['util-reloaded:2',
                 'orphan-reloaded:2',
                 'using-util-reloaded:2'],
                [util.reloaded, orphan.reloaded, using_util.reloaded])

            # Modify util - reload **and** remove of deleted happens
            with open(fp_util, 'w') as f:
                f.write(util_contents)
            yield zleep(0.02)   # Allow DirectoryWatcher some reactor time

            util, orphan, using_util = d.getModule('util'), d.getModule('orphan'), d.getModule('using-util')
            self.assertEquals(None, orphan)
            self.assertEquals(
                ['util-reloaded:3',
                 'using-util-reloaded:3'],
                [util.reloaded, using_util.reloaded])
            self.assertEquals('using-util-reloaded:3 - util-reloaded:3', using_util.using())

            # cleanup
            reactor().removeReader(sok=directoryWatcherReadFD)
开发者ID:seecr,项目名称:meresco-html,代码行数:66,代码来源:dynamichtmltest.py


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