Edgewall Software

Ticket #185: xpath_text_tests.diff

File xpath_text_tests.diff, 1.4 KB (added by mestudd@…, 8 years ago)

Added tests to check foo/bar/text()

  • genshi/tests/path.py

     
    178178        xml = XML('<root><item>Foo</item><item>Bar</item></root>')
    179179        self.assertEqual('FooBar', path.select(xml).render())
    180180
     181        path = Path('item/name/text()')
     182        xml = XML('<root><item><name>Foo</name><sub><name>Bar</name></sub></item></root>')
     183        self.assertEqual('Foo', path.select(xml).render())
     184
    181185    def test_3step(self):
    182186        xml = XML('<root><foo><bar/></foo></root>')
    183187        path = Path('foo/*')
     
    209213        self.assertEqual('<Path "child::text()">', repr(path))
    210214        self.assertEqual('Some text in here.', path.select(xml).render())
    211215
     216        xml = XML('<root><item><bar>Some text </bar><baz><bar>in here.</bar></baz></item></root>')
     217        path = Path('item//bar/text()')
     218        self.assertEqual('<Path "child::item/descendant-or-self::node()/child::bar/child::text()">', repr(path))
     219        self.assertEqual('Some text in here.', path.select(xml).render())
     220
     221        path = Path('item/bar/text()')
     222        self.assertEqual('<Path "child::item/child::bar/child::text()">', repr(path))
     223        self.assertEqual('Some text', path.select(xml).render())
     224
    212225    def test_node_type_node(self):
    213226        xml = XML('<root>Some text <br/>in here.</root>')
    214227        path = Path('node()')