Skip to content

Commit

Permalink
Python: Improve refleak checker for Python 3.12.
Browse files Browse the repository at this point in the history
Each call to `unittest.TestResult.addDuration` increases the total refcount.
The refleak checker now mocks this function to get consistent values.

PiperOrigin-RevId: 717548068
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Jan 20, 2025
1 parent e3ac4c9 commit 336d6f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/google/protobuf/internal/testing_refleaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def addFailure(self, test, error):
def addSkip(self, test, reason):
pass

def addDuration(self, test, duration):
pass


class ReferenceLeakCheckerMixin(object):
"""A mixin class for TestCase, which checks reference counts."""
Expand All @@ -59,7 +62,7 @@ def run(self, result=None):
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

Expand Down

0 comments on commit 336d6f0

Please sign in to comment.