Skip to content

Commit 603a5d9

Browse files
committed
Centralise mem leak threshold and set it to 30%
1 parent 29cb637 commit 603a5d9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/test_method.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import tracemalloc
1010
from Python.Test import MethodTest
1111

12+
MEM_LEAK_THRESHOLD = 0.3
13+
1214
@pytest.fixture(scope="function")
1315
def memory_usage_tracking():
1416
was_tracing = tracemalloc.is_tracing()
@@ -985,7 +987,7 @@ def test_getting_generic_method_binding_does_not_leak_memory(memory_usage_tracki
985987

986988
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
987989
# Increased from 50% to ensure that it works on Windows with Python >3.13
988-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
990+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * MEM_LEAK_THRESHOLD
989991

990992
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
991993

@@ -1026,7 +1028,7 @@ def test_getting_overloaded_method_binding_does_not_leak_memory(memory_usage_tra
10261028
bytesLeakedPerIteration = processBytesDelta / iterations
10271029

10281030
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
1029-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
1031+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * MEM_LEAK_THRESHOLD
10301032

10311033
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
10321034

@@ -1069,7 +1071,7 @@ def test_getting_method_overloads_binding_does_not_leak_memory(memory_usage_trac
10691071
bytesLeakedPerIteration = processBytesDelta / iterations
10701072

10711073
# Allow 90% threshold - this shows the original issue is fixed, which leaks the full allocated bytes per iteration
1072-
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * 0.1
1074+
failThresholdBytesLeakedPerIteration = bytesAllocatedPerIteration * MEM_LEAK_THRESHOLD
10731075

10741076
assert bytesLeakedPerIteration < failThresholdBytesLeakedPerIteration
10751077

0 commit comments

Comments
 (0)