本文整理汇总了Python中osc2.util.xpath.XPathBuilder.context方法的典型用法代码示例。如果您正苦于以下问题:Python XPathBuilder.context方法的具体用法?Python XPathBuilder.context怎么用?Python XPathBuilder.context使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osc2.util.xpath.XPathBuilder
的用法示例。
在下文中一共展示了XPathBuilder.context方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_context_item2
# 需要导入模块: from osc2.util.xpath import XPathBuilder [as 别名]
# 或者: from osc2.util.xpath.XPathBuilder import context [as 别名]
def test_context_item2(self):
"""test context item (disabled) for the initial expression"""
xpb = XPathBuilder(context_item=False)
xp1 = xpb.foo.bar
xp1_exp = '/foo/bar'
xp2 = xpb.context(True).foo.bar
xp2_exp = './foo/bar'
self.assertEqual(xp1.tostring(), xp1_exp)
self.assertEqual(xp2.tostring(), xp2_exp)
self.assertFalse(xpb.context_item)
示例2: test_context_item4
# 需要导入模块: from osc2.util.xpath import XPathBuilder [as 别名]
# 或者: from osc2.util.xpath.XPathBuilder import context [as 别名]
def test_context_item4(self):
"""test context item (nested expression) (written ops)"""
xpb = XPathBuilder()
xp = xpb.foo.where(xpb.context(True).bar.log_or(xpb.context(True).baz))
exp = '/foo[./bar or ./baz]'
self.assertEqual(xp.tostring(), exp)
示例3: test_context_item3
# 需要导入模块: from osc2.util.xpath import XPathBuilder [as 别名]
# 或者: from osc2.util.xpath.XPathBuilder import context [as 别名]
def test_context_item3(self):
"""test context item (nested expression)"""
xpb = XPathBuilder()
xp = xpb.foo[xpb.context(True).bar | xpb.context(True).baz]
exp = '/foo[./bar or ./baz]'
self.assertEqual(xp.tostring(), exp)