Skip to content

Commit eec97e8

Browse files
committed
Simplify tolerance reasoning in java_heap test
1 parent fa38c52 commit eec97e8

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

tests/it/java_heap.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22
Test scyjava JVM memory-related functions.
33
"""
44

5-
import math
6-
75
from assertpy import assert_that
86

97
import scyjava
108

11-
12-
def magnitude(x: int) -> int:
13-
return math.floor(math.log10(abs(x)))
14-
15-
169
mb_initial = 50 # initial MB of memory to snarf up
10+
mb_tolerance = 10 # ceiling of expected MB in use
1711

1812
scyjava.config.set_heap_min(mb=mb_initial)
1913
scyjava.config.set_heap_max(gb=1)
@@ -35,9 +29,7 @@ def magnitude(x: int) -> int:
3529
).is_less_than_or_equal_to(mb_max)
3630
assert_that(mb_max, "maximum heap size should be approx. 1 GB").is_between(900, 1024)
3731

38-
tolerance = pow(10, magnitude(mb_initial))
39-
40-
assert_that(mb_used, "most memory should be available").is_less_than(tolerance)
32+
assert_that(mb_used, "most memory should be available").is_less_than(mb_tolerance)
4133
assert_that(mb_total, "total memory should be close to initial").is_close_to(
42-
mb_initial, tolerance=tolerance
34+
mb_initial, tolerance=mb_tolerance
4335
)

0 commit comments

Comments
 (0)