fix: adjust refcount test for python3.14

References:
- https://docs.python.org/3.14/whatsnew/3.14.html#optimizations
- https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-refcount

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-10-08 18:30:46 +05:30
parent 0c3be512db
commit 770024f048
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -193,14 +193,16 @@ class TestPerformance(IntegrationTestCase):
"""
query = "select * from tabUser"
expected_refcount = 1 if sys.version_info >= (3, 14) else 2
for kwargs in ({}, {"as_dict": True}, {"as_list": True}):
result = frappe.db.sql(query, **kwargs)
self.assertEqual(sys.getrefcount(result), 2) # Note: This always returns +1
self.assertEqual(sys.getrefcount(result), expected_refcount) # Note: This always returns +1
self.assertFalse(gc.get_referrers(result))
def test_no_cyclic_references(self):
doc = frappe.get_doc("User", "Administrator")
self.assertEqual(sys.getrefcount(doc), 2) # Note: This always returns +1
expected_refcount = 1 if sys.version_info >= (3, 14) else 2
self.assertEqual(sys.getrefcount(doc), expected_refcount) # Note: This always returns +1
def test_get_doc_cache_calls(self):
frappe.get_doc("User", "Administrator")