|
|
||
| for i in range(10): | ||
| dct.copy() | ||
| first_ref_count = gettotalrefcount() |
There was a problem hiding this comment.
Should it be in the loop?
| 'debug build required') | ||
| def test_copy_global_refcount(self): | ||
| # See issue #34042 for more details. | ||
| first_ref_count = second_ref_count = None |
There was a problem hiding this comment.
What is the reason of this initialization?
|
|
||
| for i in range(10): | ||
| dct.copy() | ||
| first_ref_count = gettotalrefcount() |
There was a problem hiding this comment.
Why getting the total for each iteration of the loop?
|
@vstinner @serhiy-storchaka The test is structured in a weird way because that's the only way how I can get it stable on my machine. And yet, here's a CI failure: Any suggestions on how I can write a reliable test for |
Since this is debug feature, I'm OK for this instead of maintain cryptic, fragile test. |
|
What about using dct = {'a': 1}
support.gc_collect()
first_ref_count = sys.gettotalrefcount()
for i in range(1000):
dct.copy()
support.gc_collect()
second_ref_count = sys.gettotalrefcount()
self.assertAlmostEqual(first_ref_count, second_ref_count, delta=10) |
|
Please don't use fragile tests. I already have enough issues with existing fragile tests. +1 to commit without tests. |
Honestly, Python internals are too complex to get a reliable total reference count. I'm ok to remove the test. regrtest usually runs a test 3 times to "warmup caches" before checking for reference leaks, and also use many low-level "cleanup" functions to help to get reliable reference counts. |
|
Thanks @1st1 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
GH-8143 is a backport of this pull request to the 3.7 branch. |
https://bugs.python.org/issue34042