File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1919from io import BytesIO , StringIO
2020import codecs
2121import os .path
22+ import pyexpat
2223import shutil
2324import sys
2425from urllib .error import URLError
@@ -1214,6 +1215,30 @@ def test_expat_incremental_reset(self):
12141215
12151216 self .assertEqual (result .getvalue (), start + b"<doc>text</doc>" )
12161217
1218+ def test_expat_incremental_reparse_deferral (self ):
1219+ result = BytesIO ()
1220+ xmlgen = XMLGenerator (result )
1221+ parser = create_parser ()
1222+ parser .setContentHandler (xmlgen )
1223+
1224+ # This artificial chunking triggers reparse deferral with Expat >=2.6.0
1225+ parser .feed ("<doc " )
1226+ parser .feed (">" )
1227+
1228+ if pyexpat .version_info >= (2 , 6 , 0 ):
1229+ self .assertEqual (result .getvalue (), start )
1230+ else :
1231+ self .assertEqual (result .getvalue (), start + b"<doc>" )
1232+
1233+ parser .flush () # no-op for Expat <2.6.0
1234+
1235+ self .assertEqual (result .getvalue (), start + b"<doc>" )
1236+
1237+ parser .feed ("</doc>" )
1238+ parser .close ()
1239+
1240+ self .assertEqual (result .getvalue (), start + b"<doc></doc>" )
1241+
12171242 # ===== Locator support
12181243
12191244 def test_expat_locator_noinfo (self ):
You can’t perform that action at this time.
0 commit comments