MCPcopy Index your code
hub / github.com/python/cpython / test_setroot

Method test_setroot

Lib/test/test_xml_etree.py:229–246  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

227 tree = ET.ElementTree(ET.ElementTree())
228
229 def test_setroot(self):
230 # Test _setroot behavior.
231
232 tree = ET.ElementTree()
233 element = ET.Element("tag")
234 tree._setroot(element)
235 self.assertEqual(tree.getroot().tag, "tag")
236 self.assertEqual(tree.getroot(), element)
237
238 # Test behavior with an invalid root element
239
240 tree = ET.ElementTree()
241 with self.assertRaises(TypeError):
242 tree._setroot("")
243 with self.assertRaises(TypeError):
244 tree._setroot(ET.ElementTree())
245 with self.assertRaises(TypeError):
246 tree._setroot(None)
247
248 def test_interface(self):
249 # Test element tree interface.

Callers

nothing calls this directly

Calls 4

_setrootMethod · 0.95
getrootMethod · 0.95
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected