@@ -114,7 +114,7 @@ def check_partial(self, input, partialresults):
114114 q = Queue (b"" )
115115 r = codecs .getreader (self .encoding )(q )
116116 result = ""
117- for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults ):
117+ for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults , strict = True ):
118118 q .write (bytes ([c ]))
119119 result += r .read ()
120120 self .assertEqual (result , partialresult )
@@ -125,7 +125,7 @@ def check_partial(self, input, partialresults):
125125 # do the check again, this time using an incremental decoder
126126 d = codecs .getincrementaldecoder (self .encoding )()
127127 result = ""
128- for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults ):
128+ for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults , strict = True ):
129129 result += d .decode (bytes ([c ]))
130130 self .assertEqual (result , partialresult )
131131 # check that there's nothing left in the buffers
@@ -135,7 +135,7 @@ def check_partial(self, input, partialresults):
135135 # Check whether the reset method works properly
136136 d .reset ()
137137 result = ""
138- for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults ):
138+ for (c , partialresult ) in zip (input .encode (self .encoding ), partialresults , strict = True ):
139139 result += d .decode (bytes ([c ]))
140140 self .assertEqual (result , partialresult )
141141 # check that there's nothing left in the buffers
@@ -2353,7 +2353,11 @@ def test_unicode_escape(self):
23532353 (r"\x5c\x55\x30\x30\x31\x31\x30\x30\x30\x30" , 10 ))
23542354
23552355
2356- class UnicodeEscapeTest (unittest .TestCase ):
2356+ class UnicodeEscapeTest (ReadTest , unittest .TestCase ):
2357+ encoding = "unicode-escape"
2358+
2359+ test_lone_surrogates = None
2360+
23572361 def test_empty (self ):
23582362 self .assertEqual (codecs .unicode_escape_encode ("" ), (b"" , 0 ))
23592363 self .assertEqual (codecs .unicode_escape_decode (b"" ), ("" , 0 ))
@@ -2440,6 +2444,44 @@ def test_decode_errors(self):
24402444 self .assertEqual (decode (br"\U00110000" , "ignore" ), ("" , 10 ))
24412445 self .assertEqual (decode (br"\U00110000" , "replace" ), ("\ufffd " , 10 ))
24422446
2447+ def test_partial (self ):
2448+ self .check_partial (
2449+ "\x00 \t \n \r \\ \xff \uffff \U00010000 " ,
2450+ [
2451+ '' ,
2452+ '' ,
2453+ '' ,
2454+ '\x00 ' ,
2455+ '\x00 ' ,
2456+ '\x00 \t ' ,
2457+ '\x00 \t ' ,
2458+ '\x00 \t \n ' ,
2459+ '\x00 \t \n ' ,
2460+ '\x00 \t \n \r ' ,
2461+ '\x00 \t \n \r ' ,
2462+ '\x00 \t \n \r \\ ' ,
2463+ '\x00 \t \n \r \\ ' ,
2464+ '\x00 \t \n \r \\ ' ,
2465+ '\x00 \t \n \r \\ ' ,
2466+ '\x00 \t \n \r \\ \xff ' ,
2467+ '\x00 \t \n \r \\ \xff ' ,
2468+ '\x00 \t \n \r \\ \xff ' ,
2469+ '\x00 \t \n \r \\ \xff ' ,
2470+ '\x00 \t \n \r \\ \xff ' ,
2471+ '\x00 \t \n \r \\ \xff ' ,
2472+ '\x00 \t \n \r \\ \xff \uffff ' ,
2473+ '\x00 \t \n \r \\ \xff \uffff ' ,
2474+ '\x00 \t \n \r \\ \xff \uffff ' ,
2475+ '\x00 \t \n \r \\ \xff \uffff ' ,
2476+ '\x00 \t \n \r \\ \xff \uffff ' ,
2477+ '\x00 \t \n \r \\ \xff \uffff ' ,
2478+ '\x00 \t \n \r \\ \xff \uffff ' ,
2479+ '\x00 \t \n \r \\ \xff \uffff ' ,
2480+ '\x00 \t \n \r \\ \xff \uffff ' ,
2481+ '\x00 \t \n \r \\ \xff \uffff ' ,
2482+ '\x00 \t \n \r \\ \xff \uffff \U00010000 ' ,
2483+ ]
2484+ )
24432485
24442486class RawUnicodeEscapeTest (unittest .TestCase ):
24452487 def test_empty (self ):
0 commit comments