Skip to content

Commit

Permalink
- test.util.test_xpath: added testcases for a relative path expression
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-h committed Nov 22, 2012
1 parent ab99862 commit 9a9c285
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/util/test_xpath.py
Expand Up @@ -601,5 +601,26 @@ def test_dummy6(self):
exp = '/bar'
self.assertEqual(xp.tostring(), exp)

def test_relative1(self):
"""test a relative path expression 1"""
xpb = XPathBuilder(is_relative=True)
xp = xpb.foo
exp = 'foo'
self.assertEqual(xp.tostring(), exp)

def test_relative2(self):
"""test a relative path expression 2"""
xpb = XPathBuilder(is_relative=True)
xp = xpb.foo.bar.x
exp = 'foo/bar/x'
self.assertEqual(xp.tostring(), exp)

def test_relative3(self):
"""test a relative path expression (relative method)"""
xpb = XPathBuilder()
xp = xpb.foo.bar[xpb.relative(True).x.y.log_or(xpb.relative(True).z)]
exp = '/foo/bar[x/y or z]'
self.assertEqual(xp.tostring(), exp)

if __name__ == '__main__':
unittest.main()

0 comments on commit 9a9c285

Please sign in to comment.