diff options
author | Eli Bendersky <eliben@gmail.com> | 2012-05-29 12:45:16 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2012-05-29 12:45:16 (GMT) |
commit | 58d548dff1a6970b24f09334051fa627d9aba339 (patch) | |
tree | c16a967e32668cc73cf86aaf31bc8d9844928dd2 /Lib/test/test_xml_etree.py | |
parent | d3f0882dfb3a15d604de1b1620b2bf8de9d643bb (diff) | |
download | cpython-58d548dff1a6970b24f09334051fa627d9aba339.zip cpython-58d548dff1a6970b24f09334051fa627d9aba339.tar.gz cpython-58d548dff1a6970b24f09334051fa627d9aba339.tar.bz2 |
Issue #14007: make TreeBuilder an actual type exposed from _elementtree, and subclassable.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r-- | Lib/test/test_xml_etree.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index cdba2b6..74fade5 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -1979,6 +1979,20 @@ class TreeBuilderTest(unittest.TestCase): parser.feed(self.sample1) self.assertIsNone(parser.close()) + def test_subclass(self): + class MyTreeBuilder(ET.TreeBuilder): + def foobar(self, x): + return x * 2 + + tb = MyTreeBuilder() + self.assertEqual(tb.foobar(10), 20) + + parser = ET.XMLParser(target=tb) + parser.feed(self.sample1) + + e = parser.close() + self.assertEqual(e.tag, 'html') + # XXX in _elementtree, the constructor of TreeBuilder expects no # arguments @unittest.expectedFailure |