1
1
import unittest
2
2
from test .support import import_helper
3
3
4
- _testcapi = import_helper .import_module ('_testcapi ' )
4
+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi ' )
5
5
from _testcapi import PY_SSIZE_T_MIN , PY_SSIZE_T_MAX
6
6
7
7
NULL = None
@@ -19,7 +19,7 @@ def __bytes__(self):
19
19
class CAPITest (unittest .TestCase ):
20
20
def test_check (self ):
21
21
# Test PyBytes_Check()
22
- check = _testcapi .bytes_check
22
+ check = _testlimitedcapi .bytes_check
23
23
self .assertTrue (check (b'abc' ))
24
24
self .assertFalse (check ('abc' ))
25
25
self .assertFalse (check (bytearray (b'abc' )))
@@ -33,7 +33,7 @@ def test_check(self):
33
33
34
34
def test_checkexact (self ):
35
35
# Test PyBytes_CheckExact()
36
- check = _testcapi .bytes_checkexact
36
+ check = _testlimitedcapi .bytes_checkexact
37
37
self .assertTrue (check (b'abc' ))
38
38
self .assertFalse (check ('abc' ))
39
39
self .assertFalse (check (bytearray (b'abc' )))
@@ -47,7 +47,7 @@ def test_checkexact(self):
47
47
48
48
def test_fromstringandsize (self ):
49
49
# Test PyBytes_FromStringAndSize()
50
- fromstringandsize = _testcapi .bytes_fromstringandsize
50
+ fromstringandsize = _testlimitedcapi .bytes_fromstringandsize
51
51
52
52
self .assertEqual (fromstringandsize (b'abc' ), b'abc' )
53
53
self .assertEqual (fromstringandsize (b'abc' , 2 ), b'ab' )
@@ -65,7 +65,7 @@ def test_fromstringandsize(self):
65
65
66
66
def test_fromstring (self ):
67
67
# Test PyBytes_FromString()
68
- fromstring = _testcapi .bytes_fromstring
68
+ fromstring = _testlimitedcapi .bytes_fromstring
69
69
70
70
self .assertEqual (fromstring (b'abc\0 def' ), b'abc' )
71
71
self .assertEqual (fromstring (b'' ), b'' )
@@ -74,7 +74,7 @@ def test_fromstring(self):
74
74
75
75
def test_fromobject (self ):
76
76
# Test PyBytes_FromObject()
77
- fromobject = _testcapi .bytes_fromobject
77
+ fromobject = _testlimitedcapi .bytes_fromobject
78
78
79
79
self .assertEqual (fromobject (b'abc' ), b'abc' )
80
80
self .assertEqual (fromobject (bytearray (b'abc' )), b'abc' )
@@ -88,7 +88,7 @@ def test_fromobject(self):
88
88
89
89
def test_size (self ):
90
90
# Test PyBytes_Size()
91
- size = _testcapi .bytes_size
91
+ size = _testlimitedcapi .bytes_size
92
92
93
93
self .assertEqual (size (b'abc' ), 3 )
94
94
self .assertEqual (size (BytesSubclass (b'abc' )), 3 )
@@ -100,7 +100,7 @@ def test_size(self):
100
100
101
101
def test_asstring (self ):
102
102
"""Test PyBytes_AsString()"""
103
- asstring = _testcapi .bytes_asstring
103
+ asstring = _testlimitedcapi .bytes_asstring
104
104
105
105
self .assertEqual (asstring (b'abc' , 4 ), b'abc\0 ' )
106
106
self .assertEqual (asstring (b'abc\0 def' , 8 ), b'abc\0 def\0 ' )
@@ -111,8 +111,8 @@ def test_asstring(self):
111
111
112
112
def test_asstringandsize (self ):
113
113
"""Test PyBytes_AsStringAndSize()"""
114
- asstringandsize = _testcapi .bytes_asstringandsize
115
- asstringandsize_null = _testcapi .bytes_asstringandsize_null
114
+ asstringandsize = _testlimitedcapi .bytes_asstringandsize
115
+ asstringandsize_null = _testlimitedcapi .bytes_asstringandsize_null
116
116
117
117
self .assertEqual (asstringandsize (b'abc' , 4 ), (b'abc\0 ' , 3 ))
118
118
self .assertEqual (asstringandsize (b'abc\0 def' , 8 ), (b'abc\0 def\0 ' , 7 ))
@@ -128,7 +128,7 @@ def test_asstringandsize(self):
128
128
129
129
def test_repr (self ):
130
130
# Test PyBytes_Repr()
131
- bytes_repr = _testcapi .bytes_repr
131
+ bytes_repr = _testlimitedcapi .bytes_repr
132
132
133
133
self .assertEqual (bytes_repr (b'''abc''' , 0 ), r"""b'abc'""" )
134
134
self .assertEqual (bytes_repr (b'''abc''' , 1 ), r"""b'abc'""" )
@@ -149,7 +149,7 @@ def test_repr(self):
149
149
def test_concat (self , concat = None ):
150
150
"""Test PyBytes_Concat()"""
151
151
if concat is None :
152
- concat = _testcapi .bytes_concat
152
+ concat = _testlimitedcapi .bytes_concat
153
153
154
154
self .assertEqual (concat (b'abc' , b'def' ), b'abcdef' )
155
155
self .assertEqual (concat (b'a\0 b' , b'c\0 d' ), b'a\0 bc\0 d' )
@@ -182,11 +182,11 @@ def test_concat(self, concat=None):
182
182
183
183
def test_concatanddel (self ):
184
184
"""Test PyBytes_ConcatAndDel()"""
185
- self .test_concat (_testcapi .bytes_concatanddel )
185
+ self .test_concat (_testlimitedcapi .bytes_concatanddel )
186
186
187
187
def test_decodeescape (self ):
188
188
"""Test PyBytes_DecodeEscape()"""
189
- decodeescape = _testcapi .bytes_decodeescape
189
+ decodeescape = _testlimitedcapi .bytes_decodeescape
190
190
191
191
self .assertEqual (decodeescape (b'abc' ), b'abc' )
192
192
self .assertEqual (decodeescape (br'\t\n\r\x0b\x0c\x00\\\'\"' ),
0 commit comments