@@ -130,62 +130,6 @@ raiseTestError(const char* test_name, const char* msg)
130130 return NULL ;
131131}
132132
133- static PyObject *
134- test_pyset_add_exact_set (PyObject * self , PyObject * Py_UNUSED (ignored ))
135- {
136- // Test: Adding to a regular set
137- PyObject * set = PySet_New (NULL );
138- if (set == NULL ) {
139- return NULL ;
140- }
141- PyObject * one = PyLong_FromLong (1 );
142- assert (one );
143-
144- if (PySet_Add (set , one ) < 0 ) {
145- Py_DECREF (set );
146- return raiseTestError ("test_pyset_add_exact_set" ,
147- "PySet_Add to empty set failed" );
148- }
149- if (PySet_Size (set ) != 1 ) {
150- Py_DECREF (set );
151- return raiseTestError ("test_pyset_add_exact_set" ,
152- "set size should be 1 after adding one element" );
153- }
154- if (PySet_Contains (set , one ) != 1 ) {
155- Py_DECREF (set );
156- return raiseTestError ("test_pyset_add_exact_set" ,
157- "set should contain the added element" );
158- }
159- Py_DECREF (set );
160-
161- // Test: Adding unhashable item should raise TypeError
162- set = PySet_New (NULL );
163- if (set == NULL ) {
164- return NULL ;
165- }
166- PyObject * unhashable = PyList_New (0 );
167- if (unhashable == NULL ) {
168- Py_DECREF (set );
169- return NULL ;
170- }
171- if (PySet_Add (set , unhashable ) != -1 ) {
172- Py_DECREF (unhashable );
173- Py_DECREF (set );
174- return raiseTestError ("test_pyset_add_exact_set" ,
175- "PySet_Add with unhashable should fail" );
176- }
177- if (!PyErr_ExceptionMatches (PyExc_TypeError )) {
178- Py_DECREF (unhashable );
179- Py_DECREF (set );
180- return raiseTestError ("test_pyset_add_exact_set" ,
181- "PySet_Add with unhashable should raise TypeError" );
182- }
183- PyErr_Clear ();
184- Py_DECREF (unhashable );
185- Py_DECREF (set );
186-
187- Py_RETURN_NONE ;
188- }
189133
190134static PyObject *
191135test_frozenset_add_in_capi (PyObject * self , PyObject * Py_UNUSED (obj ))
@@ -223,48 +167,11 @@ test_frozenset_add_in_capi(PyObject *self, PyObject *Py_UNUSED(obj))
223167}
224168
225169static PyObject *
226- test_pyset_add_frozenset (PyObject * self , PyObject * Py_UNUSED (ignored ))
170+ test_frozenset_add_in_capi_tracking (PyObject * self , PyObject * Py_UNUSED (ignored ))
227171{
228172 PyObject * one = PyLong_FromLong (1 );
229173 assert (one );
230174
231- // Test: Adding to uniquely-referenced frozenset should succeed
232- PyObject * frozenset = PyFrozenSet_New (NULL );
233- if (frozenset == NULL ) {
234- return NULL ;
235- }
236-
237- // frozenset is uniquely referenced here, so PySet_Add should work
238- if (PySet_Add (frozenset , one ) < 0 ) {
239- Py_DECREF (frozenset );
240- return raiseTestError ("test_pyset_add_frozenset" ,
241- "PySet_Add to uniquely-referenced frozenset failed" );
242- }
243- Py_DECREF (frozenset );
244-
245- // Test: Adding to non-uniquely-referenced frozenset should raise SystemError
246- frozenset = PyFrozenSet_New (NULL );
247- if (frozenset == NULL ) {
248- return NULL ;
249- }
250- Py_INCREF (frozenset ); // Make it non-uniquely referenced
251-
252- if (PySet_Add (frozenset , one ) != -1 ) {
253- Py_DECREF (frozenset );
254- Py_DECREF (frozenset );
255- return raiseTestError ("test_pyset_add_frozenset" ,
256- "PySet_Add to non-uniquely-referenced frozenset should fail" );
257- }
258- if (!PyErr_ExceptionMatches (PyExc_SystemError )) {
259- Py_DECREF (frozenset );
260- Py_DECREF (frozenset );
261- return raiseTestError ("test_pyset_add_frozenset" ,
262- "PySet_Add to non-uniquely-referenced frozenset should raise SystemError" );
263- }
264- PyErr_Clear ();
265- Py_DECREF (frozenset );
266- Py_DECREF (frozenset );
267-
268175 // Test: GC tracking - frozenset with only immutable items should not be tracked
269176 frozenset = PyFrozenSet_New (NULL );
270177 if (frozenset == NULL ) {
@@ -379,7 +286,6 @@ static PyMethodDef test_methods[] = {
379286 {"test_frozenset_add_in_capi" , test_frozenset_add_in_capi , METH_NOARGS },
380287 {"test_set_contains_does_not_convert_unhashable_key" ,
381288 test_set_contains_does_not_convert_unhashable_key , METH_NOARGS },
382- {"test_pyset_add_exact_set" , test_pyset_add_exact_set , METH_NOARGS },
383289 {"test_pyset_add_frozenset" , test_pyset_add_frozenset , METH_NOARGS },
384290
385291 {NULL },
0 commit comments