22
33from test .support import import_helper
44
5- # Skip this test if the _testcapi or _testinternalcapi modules aren't available.
5+ # Skip this test if the _testcapi, _testlimitedcapi or _testinternalcapi
6+ # modules aren't available.
67_testcapi = import_helper .import_module ('_testcapi' )
8+ _testlimitedcapi = import_helper .import_module ('_testlimitedcapi' )
79_testinternalcapi = import_helper .import_module ('_testinternalcapi' )
810
911class set_subclass (set ):
@@ -23,7 +25,7 @@ def assertImmutable(self, action, *args):
2325
2426class TestSetCAPI (BaseSetTests , unittest .TestCase ):
2527 def test_set_check (self ):
26- check = _testcapi .set_check
28+ check = _testlimitedcapi .set_check
2729 self .assertTrue (check (set ()))
2830 self .assertTrue (check ({1 , 2 }))
2931 self .assertFalse (check (frozenset ()))
@@ -33,7 +35,7 @@ def test_set_check(self):
3335 # CRASHES: check(NULL)
3436
3537 def test_set_check_exact (self ):
36- check = _testcapi .set_checkexact
38+ check = _testlimitedcapi .set_checkexact
3739 self .assertTrue (check (set ()))
3840 self .assertTrue (check ({1 , 2 }))
3941 self .assertFalse (check (frozenset ()))
@@ -43,7 +45,7 @@ def test_set_check_exact(self):
4345 # CRASHES: check(NULL)
4446
4547 def test_frozenset_check (self ):
46- check = _testcapi .frozenset_check
48+ check = _testlimitedcapi .frozenset_check
4749 self .assertFalse (check (set ()))
4850 self .assertTrue (check (frozenset ()))
4951 self .assertTrue (check (frozenset ({1 , 2 })))
@@ -53,7 +55,7 @@ def test_frozenset_check(self):
5355 # CRASHES: check(NULL)
5456
5557 def test_frozenset_check_exact (self ):
56- check = _testcapi .frozenset_checkexact
58+ check = _testlimitedcapi .frozenset_checkexact
5759 self .assertFalse (check (set ()))
5860 self .assertTrue (check (frozenset ()))
5961 self .assertTrue (check (frozenset ({1 , 2 })))
@@ -63,7 +65,7 @@ def test_frozenset_check_exact(self):
6365 # CRASHES: check(NULL)
6466
6567 def test_anyset_check (self ):
66- check = _testcapi .anyset_check
68+ check = _testlimitedcapi .anyset_check
6769 self .assertTrue (check (set ()))
6870 self .assertTrue (check ({1 , 2 }))
6971 self .assertTrue (check (frozenset ()))
@@ -74,7 +76,7 @@ def test_anyset_check(self):
7476 # CRASHES: check(NULL)
7577
7678 def test_anyset_check_exact (self ):
77- check = _testcapi .anyset_checkexact
79+ check = _testlimitedcapi .anyset_checkexact
7880 self .assertTrue (check (set ()))
7981 self .assertTrue (check ({1 , 2 }))
8082 self .assertTrue (check (frozenset ()))
@@ -85,7 +87,7 @@ def test_anyset_check_exact(self):
8587 # CRASHES: check(NULL)
8688
8789 def test_set_new (self ):
88- set_new = _testcapi .set_new
90+ set_new = _testlimitedcapi .set_new
8991 self .assertEqual (set_new ().__class__ , set )
9092 self .assertEqual (set_new (), set ())
9193 self .assertEqual (set_new ((1 , 1 , 2 )), {1 , 2 })
@@ -98,7 +100,7 @@ def test_set_new(self):
98100 set_new ((1 , {}))
99101
100102 def test_frozenset_new (self ):
101- frozenset_new = _testcapi .frozenset_new
103+ frozenset_new = _testlimitedcapi .frozenset_new
102104 self .assertEqual (frozenset_new ().__class__ , frozenset )
103105 self .assertEqual (frozenset_new (), frozenset ())
104106 self .assertEqual (frozenset_new ((1 , 1 , 2 )), frozenset ({1 , 2 }))
@@ -111,7 +113,7 @@ def test_frozenset_new(self):
111113 frozenset_new ((1 , {}))
112114
113115 def test_set_size (self ):
114- get_size = _testcapi .set_size
116+ get_size = _testlimitedcapi .set_size
115117 self .assertEqual (get_size (set ()), 0 )
116118 self .assertEqual (get_size (frozenset ()), 0 )
117119 self .assertEqual (get_size ({1 , 1 , 2 }), 2 )
@@ -134,7 +136,7 @@ def test_set_get_size(self):
134136 # CRASHES: get_size(object())
135137
136138 def test_set_contains (self ):
137- contains = _testcapi .set_contains
139+ contains = _testlimitedcapi .set_contains
138140 for cls in (set , frozenset , set_subclass , frozenset_subclass ):
139141 with self .subTest (cls = cls ):
140142 instance = cls ((1 , 2 ))
@@ -147,7 +149,7 @@ def test_set_contains(self):
147149 # CRASHES: contains(NULL, NULL)
148150
149151 def test_add (self ):
150- add = _testcapi .set_add
152+ add = _testlimitedcapi .set_add
151153 for cls in (set , set_subclass ):
152154 with self .subTest (cls = cls ):
153155 instance = cls ((1 , 2 ))
@@ -165,7 +167,7 @@ def test_add(self):
165167 # CRASHES: add(NULL, NULL)
166168
167169 def test_discard (self ):
168- discard = _testcapi .set_discard
170+ discard = _testlimitedcapi .set_discard
169171 for cls in (set , set_subclass ):
170172 with self .subTest (cls = cls ):
171173 instance = cls ((1 , 2 ))
@@ -187,7 +189,7 @@ def test_discard(self):
187189 # CRASHES: discard(NULL, NULL)
188190
189191 def test_pop (self ):
190- pop = _testcapi .set_pop
192+ pop = _testlimitedcapi .set_pop
191193 orig = (1 , 2 )
192194 for cls in (set , set_subclass ):
193195 with self .subTest (cls = cls ):
@@ -204,7 +206,7 @@ def test_pop(self):
204206 # CRASHES: pop(NULL)
205207
206208 def test_clear (self ):
207- clear = _testcapi .set_clear
209+ clear = _testlimitedcapi .set_clear
208210 for cls in (set , set_subclass ):
209211 with self .subTest (cls = cls ):
210212 instance = cls ((1 , 2 ))
0 commit comments