File tree 1 file changed +25
-0
lines changed
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 19
19
from io import BytesIO , StringIO
20
20
import codecs
21
21
import os .path
22
+ import pyexpat
22
23
import shutil
23
24
import sys
24
25
from urllib .error import URLError
@@ -1214,6 +1215,30 @@ def test_expat_incremental_reset(self):
1214
1215
1215
1216
self .assertEqual (result .getvalue (), start + b"<doc>text</doc>" )
1216
1217
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
+
1217
1242
# ===== Locator support
1218
1243
1219
1244
def test_expat_locator_noinfo (self ):
You can’t perform that action at this time.
0 commit comments