本文整理汇总了Python中zope.configuration.config.ConfigurationMachine.includepath方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationMachine.includepath方法的具体用法?Python ConfigurationMachine.includepath怎么用?Python ConfigurationMachine.includepath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zope.configuration.config.ConfigurationMachine
的用法示例。
在下文中一共展示了ConfigurationMachine.includepath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_actions_have_parents_includepath
# 需要导入模块: from zope.configuration.config import ConfigurationMachine [as 别名]
# 或者: from zope.configuration.config.ConfigurationMachine import includepath [as 别名]
def test_actions_have_parents_includepath(self):
from zope.configuration import xmlconfig
from zope.configuration.config import ConfigurationMachine
from zope.configuration.xmlconfig import registerCommonDirectives
from zope.configuration import tests
from zope.configuration.tests import simple
context = ConfigurationMachine()
fqp = _packageFile(tests, 'configure.zcml')
registerCommonDirectives(context)
before_stack = context.stack[:]
context.package = tests
# dummy action, path from "previous" include
context.includepath = (fqp,)
def _callable():
raise AssertionError("should not be called")
context.actions.append({'discriminator': None,
'callable': _callable,
})
fqn = _packageFile(tests, 'simple.zcml')
logger = LoggerStub()
with _Monkey(xmlconfig, logger=logger):
self._callFUT(context, 'simple.zcml')
self.assertEqual(len(logger.debugs), 1)
self.assertEqual(logger.debugs[0], ('include %s', (fqn,), {}))
self.assertEqual(len(context.actions), 4)
action = context.actions[0]
self.assertEqual(action['discriminator'], None)
self.assertEqual(action['callable'], _callable)
action = context.actions[1]
self.assertEqual(action['callable'], simple.file_registry.append)
self.assertEqual(action['includepath'], (fqp,))
self.assertEqual(action['args'][0].path,
_packageFile(tests, 'simple.py'))
action = context.actions[2]
self.assertEqual(action['callable'], simple.file_registry.append)
self.assertEqual(action['includepath'], (fqp,))
self.assertEqual(action['args'][0].path,
_packageFile(tests, 'simple.zcml'))
action = context.actions[3]
self.assertEqual(action['callable'], simple.file_registry.append)
self.assertEqual(action['includepath'], (fqp,))
self.assertEqual(action['args'][0].path,
_packageFile(tests, '__init__.py'))
self.assertEqual(context.stack, before_stack)
self.assertEqual(len(context._seen_files), 1)
self.assertIn(fqn, context._seen_files)