22import sys
33from test .support import import_helper
44
5- _testcapi = import_helper .import_module ('_testcapi ' )
5+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi ' )
66
77NULL = None
88
@@ -27,7 +27,7 @@ class CAPITest(unittest.TestCase):
2727
2828 def test_fromencodedobject (self ):
2929 """Test PyUnicode_FromEncodedObject()"""
30- fromencodedobject = _testcapi .unicode_fromencodedobject
30+ fromencodedobject = _testlimitedcapi .unicode_fromencodedobject
3131
3232 self .assertEqual (fromencodedobject (b'abc' , NULL ), 'abc' )
3333 self .assertEqual (fromencodedobject (b'abc' , 'ascii' ), 'abc' )
@@ -52,7 +52,7 @@ def test_fromencodedobject(self):
5252
5353 def test_decode (self ):
5454 """Test PyUnicode_Decode()"""
55- decode = _testcapi .unicode_decode
55+ decode = _testlimitedcapi .unicode_decode
5656
5757 self .assertEqual (decode (b'[\xe2 \x82 \xac ]' , 'utf-8' ), '[\u20ac ]' )
5858 self .assertEqual (decode (b'[\xa4 ]' , 'iso8859-15' ), '[\u20ac ]' )
@@ -70,7 +70,7 @@ def test_decode(self):
7070
7171 def test_asencodedstring (self ):
7272 """Test PyUnicode_AsEncodedString()"""
73- asencodedstring = _testcapi .unicode_asencodedstring
73+ asencodedstring = _testlimitedcapi .unicode_asencodedstring
7474
7575 self .assertEqual (asencodedstring ('abc' , NULL ), b'abc' )
7676 self .assertEqual (asencodedstring ('abc' , 'ascii' ), b'abc' )
@@ -93,7 +93,7 @@ def test_asencodedstring(self):
9393
9494 def test_decodeutf8 (self ):
9595 """Test PyUnicode_DecodeUTF8()"""
96- decodeutf8 = _testcapi .unicode_decodeutf8
96+ decodeutf8 = _testlimitedcapi .unicode_decodeutf8
9797
9898 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
9999 b = s .encode ('utf-8' )
@@ -113,7 +113,7 @@ def test_decodeutf8(self):
113113
114114 def test_decodeutf8stateful (self ):
115115 """Test PyUnicode_DecodeUTF8Stateful()"""
116- decodeutf8stateful = _testcapi .unicode_decodeutf8stateful
116+ decodeutf8stateful = _testlimitedcapi .unicode_decodeutf8stateful
117117
118118 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
119119 b = s .encode ('utf-8' )
@@ -136,7 +136,7 @@ def test_decodeutf8stateful(self):
136136
137137 def test_asutf8string (self ):
138138 """Test PyUnicode_AsUTF8String()"""
139- asutf8string = _testcapi .unicode_asutf8string
139+ asutf8string = _testlimitedcapi .unicode_asutf8string
140140
141141 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
142142 self .assertEqual (asutf8string (s ), s .encode ('utf-8' ))
@@ -148,7 +148,7 @@ def test_asutf8string(self):
148148
149149 def test_decodeutf16 (self ):
150150 """Test PyUnicode_DecodeUTF16()"""
151- decodeutf16 = _testcapi .unicode_decodeutf16
151+ decodeutf16 = _testlimitedcapi .unicode_decodeutf16
152152
153153 naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
154154 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -192,7 +192,7 @@ def test_decodeutf16(self):
192192
193193 def test_decodeutf16stateful (self ):
194194 """Test PyUnicode_DecodeUTF16Stateful()"""
195- decodeutf16stateful = _testcapi .unicode_decodeutf16stateful
195+ decodeutf16stateful = _testlimitedcapi .unicode_decodeutf16stateful
196196
197197 naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
198198 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -238,7 +238,7 @@ def test_decodeutf16stateful(self):
238238
239239 def test_asutf16string (self ):
240240 """Test PyUnicode_AsUTF16String()"""
241- asutf16string = _testcapi .unicode_asutf16string
241+ asutf16string = _testlimitedcapi .unicode_asutf16string
242242
243243 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
244244 self .assertEqual (asutf16string (s ), s .encode ('utf-16' ))
@@ -250,7 +250,7 @@ def test_asutf16string(self):
250250
251251 def test_decodeutf32 (self ):
252252 """Test PyUnicode_DecodeUTF8()"""
253- decodeutf32 = _testcapi .unicode_decodeutf32
253+ decodeutf32 = _testlimitedcapi .unicode_decodeutf32
254254
255255 naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
256256 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -290,7 +290,7 @@ def test_decodeutf32(self):
290290
291291 def test_decodeutf32stateful (self ):
292292 """Test PyUnicode_DecodeUTF32Stateful()"""
293- decodeutf32stateful = _testcapi .unicode_decodeutf32stateful
293+ decodeutf32stateful = _testlimitedcapi .unicode_decodeutf32stateful
294294
295295 naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
296296 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -342,7 +342,7 @@ def test_decodeutf32stateful(self):
342342
343343 def test_asutf32string (self ):
344344 """Test PyUnicode_AsUTF32String()"""
345- asutf32string = _testcapi .unicode_asutf32string
345+ asutf32string = _testlimitedcapi .unicode_asutf32string
346346
347347 for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
348348 self .assertEqual (asutf32string (s ), s .encode ('utf-32' ))
@@ -354,7 +354,7 @@ def test_asutf32string(self):
354354
355355 def test_decodelatin1 (self ):
356356 """Test PyUnicode_DecodeLatin1()"""
357- decodelatin1 = _testcapi .unicode_decodelatin1
357+ decodelatin1 = _testlimitedcapi .unicode_decodelatin1
358358
359359 self .assertEqual (decodelatin1 (b'abc' ), 'abc' )
360360 self .assertEqual (decodelatin1 (b'abc' , 'strict' ), 'abc' )
@@ -365,7 +365,7 @@ def test_decodelatin1(self):
365365
366366 def test_aslatin1string (self ):
367367 """Test PyUnicode_AsLatin1String()"""
368- aslatin1string = _testcapi .unicode_aslatin1string
368+ aslatin1string = _testlimitedcapi .unicode_aslatin1string
369369
370370 self .assertEqual (aslatin1string ('abc' ), b'abc' )
371371 self .assertEqual (aslatin1string ('\xa1 \xa2 ' ), b'\xa1 \xa2 ' )
@@ -377,7 +377,7 @@ def test_aslatin1string(self):
377377
378378 def test_decodeascii (self ):
379379 """Test PyUnicode_DecodeASCII()"""
380- decodeascii = _testcapi .unicode_decodeascii
380+ decodeascii = _testlimitedcapi .unicode_decodeascii
381381
382382 self .assertEqual (decodeascii (b'abc' ), 'abc' )
383383 self .assertEqual (decodeascii (b'abc' , 'strict' ), 'abc' )
@@ -392,7 +392,7 @@ def test_decodeascii(self):
392392
393393 def test_asasciistring (self ):
394394 """Test PyUnicode_AsASCIIString()"""
395- asasciistring = _testcapi .unicode_asasciistring
395+ asasciistring = _testlimitedcapi .unicode_asasciistring
396396
397397 self .assertEqual (asasciistring ('abc' ), b'abc' )
398398
@@ -403,7 +403,7 @@ def test_asasciistring(self):
403403
404404 def test_decodecharmap (self ):
405405 """Test PyUnicode_DecodeCharmap()"""
406- decodecharmap = _testcapi .unicode_decodecharmap
406+ decodecharmap = _testlimitedcapi .unicode_decodecharmap
407407
408408 self .assertEqual (decodecharmap (b'\3 \0 \7 ' , {0 : 'a' , 3 : 'b' , 7 : 'c' }), 'bac' )
409409 self .assertEqual (decodecharmap (b'\1 \0 \2 ' , ['a' , 'b' , 'c' ]), 'bac' )
@@ -426,7 +426,7 @@ def test_decodecharmap(self):
426426
427427 def test_ascharmapstring (self ):
428428 """Test PyUnicode_AsCharmapString()"""
429- ascharmapstring = _testcapi .unicode_ascharmapstring
429+ ascharmapstring = _testlimitedcapi .unicode_ascharmapstring
430430
431431 self .assertEqual (ascharmapstring ('abc' , {97 : 3 , 98 : 0 , 99 : 7 }), b'\3 \0 \7 ' )
432432 self .assertEqual (ascharmapstring ('\xa1 \xa2 \xa3 ' , {0xa1 : 3 , 0xa2 : 0 , 0xa3 : 7 }), b'\3 \0 \7 ' )
@@ -443,7 +443,7 @@ def test_ascharmapstring(self):
443443
444444 def test_decodeunicodeescape (self ):
445445 """Test PyUnicode_DecodeUnicodeEscape()"""
446- decodeunicodeescape = _testcapi .unicode_decodeunicodeescape
446+ decodeunicodeescape = _testlimitedcapi .unicode_decodeunicodeescape
447447
448448 self .assertEqual (decodeunicodeescape (b'abc' ), 'abc' )
449449 self .assertEqual (decodeunicodeescape (br'\t\n\r\x0b\x0c\x00\\' ), '\t \n \r \v \f \0 \\ ' )
@@ -467,7 +467,7 @@ def test_decodeunicodeescape(self):
467467
468468 def test_asunicodeescapestring (self ):
469469 """Test PyUnicode_AsUnicodeEscapeString()"""
470- asunicodeescapestring = _testcapi .unicode_asunicodeescapestring
470+ asunicodeescapestring = _testlimitedcapi .unicode_asunicodeescapestring
471471
472472 self .assertEqual (asunicodeescapestring ('abc' ), b'abc' )
473473 self .assertEqual (asunicodeescapestring ('\t \n \r \v \f \0 \\ ' ), br'\t\n\r\x0b\x0c\x00\\' )
@@ -481,7 +481,7 @@ def test_asunicodeescapestring(self):
481481
482482 def test_decoderawunicodeescape (self ):
483483 """Test PyUnicode_DecodeRawUnicodeEscape()"""
484- decoderawunicodeescape = _testcapi .unicode_decoderawunicodeescape
484+ decoderawunicodeescape = _testlimitedcapi .unicode_decoderawunicodeescape
485485
486486 self .assertEqual (decoderawunicodeescape (b'abc' ), 'abc' )
487487 self .assertEqual (decoderawunicodeescape (b'\t \n \r \v \f \0 \\ ' ), '\t \n \r \v \f \0 \\ ' )
@@ -503,7 +503,7 @@ def test_decoderawunicodeescape(self):
503503
504504 def test_asrawunicodeescapestring (self ):
505505 """Test PyUnicode_AsRawUnicodeEscapeString()"""
506- asrawunicodeescapestring = _testcapi .unicode_asrawunicodeescapestring
506+ asrawunicodeescapestring = _testlimitedcapi .unicode_asrawunicodeescapestring
507507
508508 self .assertEqual (asrawunicodeescapestring ('abc' ), b'abc' )
509509 self .assertEqual (asrawunicodeescapestring ('\t \n \r \v \f \0 \\ ' ), b'\t \n \r \v \f \0 \\ ' )
0 commit comments