Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ace240

Browse files
committed
Clean-up duplicated code in tests
1 parent 6dc32b3 commit 4ace240

1 file changed

Lines changed: 0 additions & 46 deletions

File tree

Lib/test/test_xml_etree.py

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -736,52 +736,6 @@ def bxml(encoding):
736736
self.assertRaises(ValueError, ET.XML, xml('undefined').encode('ascii'))
737737
self.assertRaises(LookupError, ET.XML, xml('xxx').encode('ascii'))
738738

739-
def xml(encoding):
740-
return "<?xml version='1.0' encoding='%s'?><xml />" % encoding
741-
def bxml(encoding):
742-
return xml(encoding).encode(encoding)
743-
supported_encodings = [
744-
'ascii', 'utf-8', 'utf-8-sig', 'utf-16', 'utf-16be', 'utf-16le',
745-
'iso8859-1', 'iso8859-2', 'iso8859-3', 'iso8859-4', 'iso8859-5',
746-
'iso8859-6', 'iso8859-7', 'iso8859-8', 'iso8859-9', 'iso8859-10',
747-
'iso8859-13', 'iso8859-14', 'iso8859-15', 'iso8859-16',
748-
'cp437', 'cp720', 'cp737', 'cp775', 'cp850', 'cp852',
749-
'cp855', 'cp856', 'cp857', 'cp858', 'cp860', 'cp861', 'cp862',
750-
'cp863', 'cp865', 'cp866', 'cp869', 'cp874', 'cp1006', 'cp1250',
751-
'cp1251', 'cp1252', 'cp1253', 'cp1254', 'cp1255', 'cp1256',
752-
'cp1257', 'cp1258',
753-
'mac-cyrillic', 'mac-greek', 'mac-iceland', 'mac-latin2',
754-
'mac-roman', 'mac-turkish',
755-
'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'iso2022-jp-2004',
756-
'iso2022-jp-3', 'iso2022-jp-ext',
757-
'koi8-r', 'koi8-u',
758-
'hz', 'ptcp154',
759-
]
760-
for encoding in supported_encodings:
761-
self.assertEqual(ET.tostring(ET.XML(bxml(encoding))), b'<xml />')
762-
763-
unsupported_ascii_compatible_encodings = [
764-
'big5', 'big5hkscs',
765-
'cp932', 'cp949', 'cp950',
766-
'euc-jp', 'euc-jis-2004', 'euc-jisx0213', 'euc-kr',
767-
'gb2312', 'gbk', 'gb18030',
768-
'iso2022-kr', 'johab',
769-
'shift-jis', 'shift-jis-2004', 'shift-jisx0213',
770-
'utf-7',
771-
]
772-
for encoding in unsupported_ascii_compatible_encodings:
773-
self.assertRaises(ValueError, ET.XML, bxml(encoding))
774-
775-
unsupported_ascii_incompatible_encodings = [
776-
'cp037', 'cp424', 'cp500', 'cp864', 'cp875', 'cp1026', 'cp1140',
777-
'utf_32', 'utf_32_be', 'utf_32_le',
778-
]
779-
for encoding in unsupported_ascii_incompatible_encodings:
780-
self.assertRaises(ET.ParseError, ET.XML, bxml(encoding))
781-
782-
self.assertRaises(ValueError, ET.XML, xml('undefined').encode('ascii'))
783-
self.assertRaises(LookupError, ET.XML, xml('xxx').encode('ascii'))
784-
785739
def test_methods(self):
786740
# Test serialization methods.
787741

0 commit comments

Comments
 (0)