Skip to content

Commit 2177825

Browse files
Fix ElementTree tests.
1 parent 91ac15e commit 2177825

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

Lib/test/test_xml_etree.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def xml(encoding):
10141014
def bxml(encoding):
10151015
return xml(encoding).encode(encoding)
10161016
supported_encodings = [
1017-
'ascii', 'utf-8', 'utf-8-sig', 'utf-16', 'utf-16be', 'utf-16le',
1017+
'ascii', 'utf-8', 'utf-16', 'utf-16be', 'utf-16le',
10181018
'iso8859-1', 'iso8859-2', 'iso8859-3', 'iso8859-4', 'iso8859-5',
10191019
'iso8859-6', 'iso8859-7', 'iso8859-8', 'iso8859-9', 'iso8859-10',
10201020
'iso8859-13', 'iso8859-14', 'iso8859-15', 'iso8859-16',
@@ -1025,32 +1025,34 @@ def bxml(encoding):
10251025
'cp1256', 'cp1257', 'cp1258',
10261026
'mac-cyrillic', 'mac-greek', 'mac-iceland', 'mac-latin2',
10271027
'mac-roman', 'mac-turkish',
1028-
'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'iso2022-jp-2004',
1029-
'iso2022-jp-3', 'iso2022-jp-ext',
1030-
'koi8-r', 'koi8-t', 'koi8-u', 'kz1048',
1031-
'hz', 'ptcp154',
1028+
'koi8-r', 'koi8-t', 'koi8-u', 'kz1048', 'ptcp154',
10321029
]
10331030
for encoding in supported_encodings:
1034-
self.assertEqual(ET.tostring(ET.XML(bxml(encoding))), b'<xml />')
1031+
with self.subTest(encoding=encoding):
1032+
self.assertEqual(ET.tostring(ET.XML(bxml(encoding))), b'<xml />')
10351033

10361034
unsupported_ascii_compatible_encodings = [
10371035
'big5', 'big5hkscs',
10381036
'cp932', 'cp949', 'cp950',
10391037
'euc-jp', 'euc-jis-2004', 'euc-jisx0213', 'euc-kr',
10401038
'gb2312', 'gbk', 'gb18030',
1041-
'iso2022-kr', 'johab',
1039+
'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'iso2022-jp-2004',
1040+
'iso2022-jp-3', 'iso2022-jp-ext',
1041+
'iso2022-kr', 'johab', 'hz',
10421042
'shift-jis', 'shift-jis-2004', 'shift-jisx0213',
1043-
'utf-7',
1043+
'utf-7', 'utf-8-sig', 'utf8',
10441044
]
10451045
for encoding in unsupported_ascii_compatible_encodings:
1046-
self.assertRaises(ValueError, ET.XML, bxml(encoding))
1046+
with self.subTest(encoding=encoding):
1047+
self.assertRaises(ValueError, ET.XML, bxml(encoding))
10471048

10481049
unsupported_ascii_incompatible_encodings = [
10491050
'cp037', 'cp424', 'cp500', 'cp864', 'cp875', 'cp1026', 'cp1140',
10501051
'utf_32', 'utf_32_be', 'utf_32_le',
10511052
]
10521053
for encoding in unsupported_ascii_incompatible_encodings:
1053-
self.assertRaises(ET.ParseError, ET.XML, bxml(encoding))
1054+
with self.subTest(encoding=encoding):
1055+
self.assertRaises(ET.ParseError, ET.XML, bxml(encoding))
10541056

10551057
self.assertRaises(ValueError, ET.XML, xml('undefined').encode('ascii'))
10561058
self.assertRaises(LookupError, ET.XML, xml('xxx').encode('ascii'))

0 commit comments

Comments
 (0)