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

Method test_parseString_bytes

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

Source from the content-addressed store, hash-verified

230 self.check_parseString(self.data)
231
232 def test_parseString_bytes(self):
233 # UTF-8 is default encoding, US-ASCII is compatible with UTF-8,
234 # UTF-16 is autodetected
235 encodings = ('us-ascii', 'utf-8', 'utf-16', 'utf-16le', 'utf-16be')
236 for encoding in encodings:
237 self.check_parseString(xml_bytes(self.data, encoding))
238 self.check_parseString(xml_bytes(self.data, encoding, None))
239 # accept UTF-8 with BOM
240 self.check_parseString(xml_bytes(self.data, 'utf-8-sig', 'utf-8'))
241 self.check_parseString(xml_bytes(self.data, 'utf-8-sig', None))
242 # accept data with declared encoding
243 self.check_parseString(xml_bytes(self.data, 'iso-8859-1'))
244 # fail on non-UTF-8 incompatible data without declared encoding
245 with self.assertRaises(SAXException):
246 self.check_parseString(xml_bytes(self.data, 'iso-8859-1', None))
247
248class MakeParserTest(unittest.TestCase):
249 def test_make_parser2(self):

Callers

nothing calls this directly

Calls 3

check_parseStringMethod · 0.95
xml_bytesFunction · 0.85
assertRaisesMethod · 0.45

Tested by

no test coverage detected