summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2013-01-05 14:31:36 (GMT)
committerEli Bendersky <eliben@gmail.com>2013-01-05 14:31:36 (GMT)
commit3c9850aad7ef6d88d26081e062c11635af5dea8e (patch)
tree0f8e8fac0594ad61edf55390082e4df3cfaecf07 /Lib
parenta2f959169aff67901de95d9ea820c3d69119c39a (diff)
parenta873690d2c027cdd1683a9b8fd013563f9b150c8 (diff)
downloadcpython-3c9850aad7ef6d88d26081e062c11635af5dea8e.zip
cpython-3c9850aad7ef6d88d26081e062c11635af5dea8e.tar.gz
cpython-3c9850aad7ef6d88d26081e062c11635af5dea8e.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')
-rw-r--r--Lib/test/test_xml_etree.py10
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']