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

Method test_write_to_filename_with_encoding

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

Source from the content-addressed store, hash-verified

4281 self.assertEqual(f.read(), b'''<site>&#248;</site>''')
4282
4283 def test_write_to_filename_with_encoding(self):
4284 self.addCleanup(os_helper.unlink, TESTFN)
4285 tree = ET.ElementTree(ET.XML('''<site>\xf8</site>'''))
4286 tree.write(TESTFN, encoding='utf-8')
4287 with open(TESTFN, 'rb') as f:
4288 self.assertEqual(f.read(), b'''<site>\xc3\xb8</site>''')
4289
4290 tree.write(TESTFN, encoding='ISO-8859-1')
4291 with open(TESTFN, 'rb') as f:
4292 self.assertEqual(f.read(), convlinesep(
4293 b'''<?xml version='1.0' encoding='ISO-8859-1'?>\n'''
4294 b'''<site>\xf8</site>'''))
4295
4296 def test_write_to_filename_as_unicode(self):
4297 self.addCleanup(os_helper.unlink, TESTFN)

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
convlinesepFunction · 0.85
addCleanupMethod · 0.80
openFunction · 0.50
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected