Make Memory-Related Tests Less Fragile
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Feature or enhancement
Proposal:
There are a number of tests that check various aspects of memory management, typically related to some specific module or feature. Nearly every one of these tests is fairly tightly coupled to the fine details of our memory management implementation, usually tied to specific numbers.
This makes the tests fragile, often breaking with even slight changes to some aspect of memory management. [^1]
[^1]: To be fair, we don't make changes to memory management very often; clearly these tests aren't breaking all the time.
For example, in https://github.com/python/cpython/pull/121134#issuecomment-2233412265, @Fidget-Spinner says:
It fails
test.test_gdb.test_pretty_print test_capi test_exceptions test_regrtest test_repl test_sys test_tracemallocmainly because they count allocations/test out of memory situations, and the hashtable adds random allocations which breaks their careful calculations.
[^2]
[^2]: Note that those aren't necessarily the only tests that need attention here.
Ideally, we would find a way to make such tests less coupled to specific numbers, without sacrificing the accuracy of the behavior checks they are making.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the memory-sensitive tests named in the issue: test_gdb.test_pretty_print, test_capi, test_exceptions, test_regrtest, test_repl, test_sys, and test_tracemalloc. Identify which allocation or out-of-memory assertions depend on fixed counts, then determine how their behavior checks can remain accurate without those exact numbers. Done means the affected tests tolerate relevant memory-management changes while still detecting regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100