Closed
Description
Feature or enhancement
Right now CAPI tests of set
and frozenset
are quite outdated. They are defined as .test_c_api
method on set
objects, when Py_DEBUG
is set:
Lines 2371 to 2511 in 7e30821
There are several things that I can see as problematic:
- It is stored together with the production code
- These tests are mixing CAPI (
PySet_Check
), internal CAPI (_PySet_Update
), and internal function calls (set_clear_internal
) - These tests are hard to parametrize since they are called as
Lines 638 to 641 in 7e30821
- Multiple things are not tested: like
set
andfrozenset
subclasses - Test failures are not quite informative, because using C
assert
- This is a single huge test
- This test is only run under debug builds and not under "release" builds
I propose a plan to improve it:
- Move CAPI tests to
Modules/_testcapi/set.c
and addLib/test/test_capi/test_set.py
- Move internal CAPI tests
Modules/_testinternalcapi/set.c
and make sure that they are executed intest_capi.py
- Delete
test_c_api
fromsetobject.c
I plan to work on this and already have the PR for 1.
:)
Linked PRs
- gh-110525: Add CAPI tests for
set
andfrozenset
objects #110526 - gh-110525: Cover
PySet_Add
corner case withfrozenset
objects #110544 - [3.12] gh-110525: Add CAPI tests for set and frozenset objects (GH-110526). #110547
- [3.12] gh-110525: Cover PySet_Add corner case with frozenset objects (GH-110544) #110554
- gh-110525: Add tests for internal
set
CAPI #110630 - gh-110525: Delete
test_c_api
method fromset
object #110688