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

Method test_uninitialized_parser

Lib/test/test_xml_etree_c.py:124–136  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

122
123 @support.cpython_only
124 def test_uninitialized_parser(self):
125 # The interpreter shouldn't crash in case of calling methods or
126 # accessing attributes of uninitialized XMLParser objects.
127 parser = cET.XMLParser.__new__(cET.XMLParser)
128 self.assertRaises(ValueError, parser.close)
129 self.assertRaises(ValueError, parser.feed, 'foo')
130 class MockFile:
131 def read(*args):
132 return ''
133 self.assertRaises(ValueError, parser._parse_whole, MockFile())
134 self.assertRaises(ValueError, parser._setevents, None)
135 self.assertIsNone(parser.entity)
136 self.assertIsNone(parser.target)
137
138 def test_setstate_leaks(self):
139 # Test reference leaks

Callers

nothing calls this directly

Calls 4

assertIsNoneMethod · 0.80
MockFileClass · 0.70
__new__Method · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected