Python: Improve refleak checker for Python 3.12.

Each call to `unittest.TestResult.addDuration` increases the total refcount.
The refleak checker now mocks this function to get consistent values.

PiperOrigin-RevId: 717548068
pull/20018/head
Protobuf Team Bot 1 month ago committed by Copybara-Service
parent e3ac4c9342
commit 336d6f04e9
  1. 5
      python/google/protobuf/internal/testing_refleaks.py

@ -37,6 +37,9 @@ class LocalTestResult(unittest.TestResult):
def addSkip(self, test, reason):
pass
def addDuration(self, test, duration):
pass
class ReferenceLeakCheckerMixin(object):
"""A mixin class for TestCase, which checks reference counts."""
@ -59,7 +62,7 @@ class ReferenceLeakCheckerMixin(object):
super(ReferenceLeakCheckerMixin, self).run(result=result)
super(ReferenceLeakCheckerMixin, self).run(result=result)
oldrefcount = 0
oldrefcount = 0 # pylint: disable=unused-variable but needed for refcounts.
local_result = LocalTestResult(result)
num_flakes = 0

Loading…
Cancel
Save