2
2
import sys
3
3
from test .support import import_helper
4
4
5
- _testcapi = import_helper .import_module ('_testcapi ' )
5
+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi ' )
6
6
7
7
NULL = None
8
8
@@ -27,7 +27,7 @@ class CAPITest(unittest.TestCase):
27
27
28
28
def test_fromencodedobject (self ):
29
29
"""Test PyUnicode_FromEncodedObject()"""
30
- fromencodedobject = _testcapi .unicode_fromencodedobject
30
+ fromencodedobject = _testlimitedcapi .unicode_fromencodedobject
31
31
32
32
self .assertEqual (fromencodedobject (b'abc' , NULL ), 'abc' )
33
33
self .assertEqual (fromencodedobject (b'abc' , 'ascii' ), 'abc' )
@@ -52,7 +52,7 @@ def test_fromencodedobject(self):
52
52
53
53
def test_decode (self ):
54
54
"""Test PyUnicode_Decode()"""
55
- decode = _testcapi .unicode_decode
55
+ decode = _testlimitedcapi .unicode_decode
56
56
57
57
self .assertEqual (decode (b'[\xe2 \x82 \xac ]' , 'utf-8' ), '[\u20ac ]' )
58
58
self .assertEqual (decode (b'[\xa4 ]' , 'iso8859-15' ), '[\u20ac ]' )
@@ -70,7 +70,7 @@ def test_decode(self):
70
70
71
71
def test_asencodedstring (self ):
72
72
"""Test PyUnicode_AsEncodedString()"""
73
- asencodedstring = _testcapi .unicode_asencodedstring
73
+ asencodedstring = _testlimitedcapi .unicode_asencodedstring
74
74
75
75
self .assertEqual (asencodedstring ('abc' , NULL ), b'abc' )
76
76
self .assertEqual (asencodedstring ('abc' , 'ascii' ), b'abc' )
@@ -93,7 +93,7 @@ def test_asencodedstring(self):
93
93
94
94
def test_decodeutf8 (self ):
95
95
"""Test PyUnicode_DecodeUTF8()"""
96
- decodeutf8 = _testcapi .unicode_decodeutf8
96
+ decodeutf8 = _testlimitedcapi .unicode_decodeutf8
97
97
98
98
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
99
99
b = s .encode ('utf-8' )
@@ -113,7 +113,7 @@ def test_decodeutf8(self):
113
113
114
114
def test_decodeutf8stateful (self ):
115
115
"""Test PyUnicode_DecodeUTF8Stateful()"""
116
- decodeutf8stateful = _testcapi .unicode_decodeutf8stateful
116
+ decodeutf8stateful = _testlimitedcapi .unicode_decodeutf8stateful
117
117
118
118
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
119
119
b = s .encode ('utf-8' )
@@ -136,7 +136,7 @@ def test_decodeutf8stateful(self):
136
136
137
137
def test_asutf8string (self ):
138
138
"""Test PyUnicode_AsUTF8String()"""
139
- asutf8string = _testcapi .unicode_asutf8string
139
+ asutf8string = _testlimitedcapi .unicode_asutf8string
140
140
141
141
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
142
142
self .assertEqual (asutf8string (s ), s .encode ('utf-8' ))
@@ -148,7 +148,7 @@ def test_asutf8string(self):
148
148
149
149
def test_decodeutf16 (self ):
150
150
"""Test PyUnicode_DecodeUTF16()"""
151
- decodeutf16 = _testcapi .unicode_decodeutf16
151
+ decodeutf16 = _testlimitedcapi .unicode_decodeutf16
152
152
153
153
naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
154
154
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -192,7 +192,7 @@ def test_decodeutf16(self):
192
192
193
193
def test_decodeutf16stateful (self ):
194
194
"""Test PyUnicode_DecodeUTF16Stateful()"""
195
- decodeutf16stateful = _testcapi .unicode_decodeutf16stateful
195
+ decodeutf16stateful = _testlimitedcapi .unicode_decodeutf16stateful
196
196
197
197
naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
198
198
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -238,7 +238,7 @@ def test_decodeutf16stateful(self):
238
238
239
239
def test_asutf16string (self ):
240
240
"""Test PyUnicode_AsUTF16String()"""
241
- asutf16string = _testcapi .unicode_asutf16string
241
+ asutf16string = _testlimitedcapi .unicode_asutf16string
242
242
243
243
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
244
244
self .assertEqual (asutf16string (s ), s .encode ('utf-16' ))
@@ -250,7 +250,7 @@ def test_asutf16string(self):
250
250
251
251
def test_decodeutf32 (self ):
252
252
"""Test PyUnicode_DecodeUTF8()"""
253
- decodeutf32 = _testcapi .unicode_decodeutf32
253
+ decodeutf32 = _testlimitedcapi .unicode_decodeutf32
254
254
255
255
naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
256
256
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -290,7 +290,7 @@ def test_decodeutf32(self):
290
290
291
291
def test_decodeutf32stateful (self ):
292
292
"""Test PyUnicode_DecodeUTF32Stateful()"""
293
- decodeutf32stateful = _testcapi .unicode_decodeutf32stateful
293
+ decodeutf32stateful = _testlimitedcapi .unicode_decodeutf32stateful
294
294
295
295
naturalbyteorder = - 1 if sys .byteorder == 'little' else 1
296
296
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
@@ -342,7 +342,7 @@ def test_decodeutf32stateful(self):
342
342
343
343
def test_asutf32string (self ):
344
344
"""Test PyUnicode_AsUTF32String()"""
345
- asutf32string = _testcapi .unicode_asutf32string
345
+ asutf32string = _testlimitedcapi .unicode_asutf32string
346
346
347
347
for s in ['abc' , '\xa1 \xa2 ' , '\u4f60 \u597d ' , 'a\U0001f600 ' ]:
348
348
self .assertEqual (asutf32string (s ), s .encode ('utf-32' ))
@@ -354,7 +354,7 @@ def test_asutf32string(self):
354
354
355
355
def test_decodelatin1 (self ):
356
356
"""Test PyUnicode_DecodeLatin1()"""
357
- decodelatin1 = _testcapi .unicode_decodelatin1
357
+ decodelatin1 = _testlimitedcapi .unicode_decodelatin1
358
358
359
359
self .assertEqual (decodelatin1 (b'abc' ), 'abc' )
360
360
self .assertEqual (decodelatin1 (b'abc' , 'strict' ), 'abc' )
@@ -365,7 +365,7 @@ def test_decodelatin1(self):
365
365
366
366
def test_aslatin1string (self ):
367
367
"""Test PyUnicode_AsLatin1String()"""
368
- aslatin1string = _testcapi .unicode_aslatin1string
368
+ aslatin1string = _testlimitedcapi .unicode_aslatin1string
369
369
370
370
self .assertEqual (aslatin1string ('abc' ), b'abc' )
371
371
self .assertEqual (aslatin1string ('\xa1 \xa2 ' ), b'\xa1 \xa2 ' )
@@ -377,7 +377,7 @@ def test_aslatin1string(self):
377
377
378
378
def test_decodeascii (self ):
379
379
"""Test PyUnicode_DecodeASCII()"""
380
- decodeascii = _testcapi .unicode_decodeascii
380
+ decodeascii = _testlimitedcapi .unicode_decodeascii
381
381
382
382
self .assertEqual (decodeascii (b'abc' ), 'abc' )
383
383
self .assertEqual (decodeascii (b'abc' , 'strict' ), 'abc' )
@@ -392,7 +392,7 @@ def test_decodeascii(self):
392
392
393
393
def test_asasciistring (self ):
394
394
"""Test PyUnicode_AsASCIIString()"""
395
- asasciistring = _testcapi .unicode_asasciistring
395
+ asasciistring = _testlimitedcapi .unicode_asasciistring
396
396
397
397
self .assertEqual (asasciistring ('abc' ), b'abc' )
398
398
@@ -403,7 +403,7 @@ def test_asasciistring(self):
403
403
404
404
def test_decodecharmap (self ):
405
405
"""Test PyUnicode_DecodeCharmap()"""
406
- decodecharmap = _testcapi .unicode_decodecharmap
406
+ decodecharmap = _testlimitedcapi .unicode_decodecharmap
407
407
408
408
self .assertEqual (decodecharmap (b'\3 \0 \7 ' , {0 : 'a' , 3 : 'b' , 7 : 'c' }), 'bac' )
409
409
self .assertEqual (decodecharmap (b'\1 \0 \2 ' , ['a' , 'b' , 'c' ]), 'bac' )
@@ -426,7 +426,7 @@ def test_decodecharmap(self):
426
426
427
427
def test_ascharmapstring (self ):
428
428
"""Test PyUnicode_AsCharmapString()"""
429
- ascharmapstring = _testcapi .unicode_ascharmapstring
429
+ ascharmapstring = _testlimitedcapi .unicode_ascharmapstring
430
430
431
431
self .assertEqual (ascharmapstring ('abc' , {97 : 3 , 98 : 0 , 99 : 7 }), b'\3 \0 \7 ' )
432
432
self .assertEqual (ascharmapstring ('\xa1 \xa2 \xa3 ' , {0xa1 : 3 , 0xa2 : 0 , 0xa3 : 7 }), b'\3 \0 \7 ' )
@@ -443,7 +443,7 @@ def test_ascharmapstring(self):
443
443
444
444
def test_decodeunicodeescape (self ):
445
445
"""Test PyUnicode_DecodeUnicodeEscape()"""
446
- decodeunicodeescape = _testcapi .unicode_decodeunicodeescape
446
+ decodeunicodeescape = _testlimitedcapi .unicode_decodeunicodeescape
447
447
448
448
self .assertEqual (decodeunicodeescape (b'abc' ), 'abc' )
449
449
self .assertEqual (decodeunicodeescape (br'\t\n\r\x0b\x0c\x00\\' ), '\t \n \r \v \f \0 \\ ' )
@@ -467,7 +467,7 @@ def test_decodeunicodeescape(self):
467
467
468
468
def test_asunicodeescapestring (self ):
469
469
"""Test PyUnicode_AsUnicodeEscapeString()"""
470
- asunicodeescapestring = _testcapi .unicode_asunicodeescapestring
470
+ asunicodeescapestring = _testlimitedcapi .unicode_asunicodeescapestring
471
471
472
472
self .assertEqual (asunicodeescapestring ('abc' ), b'abc' )
473
473
self .assertEqual (asunicodeescapestring ('\t \n \r \v \f \0 \\ ' ), br'\t\n\r\x0b\x0c\x00\\' )
@@ -481,7 +481,7 @@ def test_asunicodeescapestring(self):
481
481
482
482
def test_decoderawunicodeescape (self ):
483
483
"""Test PyUnicode_DecodeRawUnicodeEscape()"""
484
- decoderawunicodeescape = _testcapi .unicode_decoderawunicodeescape
484
+ decoderawunicodeescape = _testlimitedcapi .unicode_decoderawunicodeescape
485
485
486
486
self .assertEqual (decoderawunicodeescape (b'abc' ), 'abc' )
487
487
self .assertEqual (decoderawunicodeescape (b'\t \n \r \v \f \0 \\ ' ), '\t \n \r \v \f \0 \\ ' )
@@ -503,7 +503,7 @@ def test_decoderawunicodeescape(self):
503
503
504
504
def test_asrawunicodeescapestring (self ):
505
505
"""Test PyUnicode_AsRawUnicodeEscapeString()"""
506
- asrawunicodeescapestring = _testcapi .unicode_asrawunicodeescapestring
506
+ asrawunicodeescapestring = _testlimitedcapi .unicode_asrawunicodeescapestring
507
507
508
508
self .assertEqual (asrawunicodeescapestring ('abc' ), b'abc' )
509
509
self .assertEqual (asrawunicodeescapestring ('\t \n \r \v \f \0 \\ ' ), b'\t \n \r \v \f \0 \\ ' )
0 commit comments