diff options
| author | Eli Bendersky <eliben@gmail.com> | 2013-01-05 14:26:39 (GMT) |
|---|---|---|
| committer | Eli Bendersky <eliben@gmail.com> | 2013-01-05 14:26:39 (GMT) |
| commit | a873690d2c027cdd1683a9b8fd013563f9b150c8 (patch) | |
| tree | c849c8cd6ec034bfbcca28a5199d509db38c9062 /Lib/test/test_xml_etree.py | |
| parent | 9f6a239cf1890602b752cf5acb0d010778bebc02 (diff) | |
| download | cpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.zip cpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.tar.gz cpython-a873690d2c027cdd1683a9b8fd013563f9b150c8.tar.bz2 | |
The get() and iter() are now able to accept keyword arguments.
In conformance with the documentation and the Python version.
Patch by Franck Michea.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
| -rw-r--r-- | Lib/test/test_xml_etree.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index 2bbf513..8913845 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1769,6 +1769,11 @@ class BasicElementTest(unittest.TestCase): self.assertEqual(flag, True) self.assertEqual(wref(), None) + def test_get_keyword_args(self): + e1 = ET.Element('foo' , x=1, y=2, z=3) + self.assertEqual(e1.get('x', default=7), 1) + self.assertEqual(e1.get('w', default=7), 7) + def test_pickle(self): # For now this test only works for the Python version of ET, # so set sys.modules accordingly because pickle uses __import__ @@ -1897,6 +1902,11 @@ class ElementIterTest(unittest.TestCase): self.assertEqual(self._ilist(doc, 'room'), ['room'] * 3) self.assertEqual(self._ilist(doc, 'house'), ['house'] * 2) + # test that iter also accepts 'tag' as a keyword arg + self.assertEqual( + summarize_list(doc.iter(tag='room')), + ['room'] * 3) + # make sure both tag=None and tag='*' return all tags all_tags = ['document', 'house', 'room', 'room', 'shed', 'house', 'room'] |
