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

Method testEncodings

Lib/test/test_minidom.py:1250–1271  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1248 doc.unlink()
1249
1250 def testEncodings(self):
1251 doc = parseString('<foo>&#x20ac;</foo>')
1252 self.assertEqual(doc.toxml(),
1253 '<?xml version="1.0" ?><foo>\u20ac</foo>')
1254 self.assertEqual(doc.toxml('utf-8'),
1255 b'<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>')
1256 self.assertEqual(doc.toxml('iso-8859-15'),
1257 b'<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>')
1258 self.assertEqual(doc.toxml('us-ascii'),
1259 b'<?xml version="1.0" encoding="us-ascii"?><foo>&#8364;</foo>')
1260 self.assertEqual(doc.toxml('utf-16'),
1261 '<?xml version="1.0" encoding="utf-16"?>'
1262 '<foo>\u20ac</foo>'.encode('utf-16'))
1263
1264 # Verify that character decoding errors raise exceptions instead
1265 # of crashing
1266 with self.assertRaises((UnicodeDecodeError, ExpatError)):
1267 parseString(
1268 b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>'
1269 )
1270
1271 doc.unlink()
1272
1273 def testStandalone(self):
1274 doc = parseString('<foo>&#x20ac;</foo>')

Callers

nothing calls this directly

Calls 6

parseStringFunction · 0.90
toxmlMethod · 0.80
assertEqualMethod · 0.45
encodeMethod · 0.45
assertRaisesMethod · 0.45
unlinkMethod · 0.45

Tested by

no test coverage detected