Changeset 1269
- Timestamp:
- Mar 20, 2014, 1:58:48 PM (10 years ago)
- Location:
- trunk/genshi
- Files:
-
- 2 edited
-
path.py (modified) (1 diff)
-
tests/path.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/genshi/path.py
r1083 r1269 1009 1009 if kind is START: 1010 1010 if self.principal_type is ATTRIBUTE and qname in data[1]: 1011 return Attrs([( self.name, data[1].get(self.name))])1011 return Attrs([(qname, data[1].get(qname))]) 1012 1012 else: 1013 1013 return data[0] == qname -
trunk/genshi/tests/path.py
r1087 r1269 15 15 import unittest 16 16 17 from genshi.core import Attrs, QName 17 18 from genshi.input import XML 18 19 from genshi.path import Path, PathParser, PathSyntaxError, GenericStrategy, \ … … 631 632 output='') 632 633 634 def test_attr_selection(self): 635 xml = XML('<root><foo bar="abc"></foo></root>') 636 path = Path('foo/@bar') 637 result = path.select(xml) 638 self.assertEqual(list(result), [ 639 Attrs([(QName('bar'), u'abc')]) 640 ]) 641 642 def test_attr_selection_with_namespace(self): 643 xml = XML( 644 '<root xmlns:ns1="http://example.com">' 645 '<foo ns1:bar="abc"></foo>' 646 '</root>') 647 path = Path('foo/@ns1:bar') 648 result = path.select(xml, namespaces={'ns1': 'http://example.com'}) 649 self.assertEqual(list(result), [ 650 Attrs([(QName('http://example.com}bar'), u'abc')]) 651 ]) 652 633 653 def _test_support(self, strategy_class, text): 634 654 path = PathParser(text, None, -1).parse()[0]
Note: See TracChangeset
for help on using the changeset viewer.
