8000 Merge pull request #67 from jschneidereit/jschneidereit/66-fix-osx-arm64 · scijava/scyjava@bf5910e · GitHub
[go: up one dir, main page]

Skip to content

Commit bf5910e

Browse files
authored
Merge pull request #67 from jschneidereit/jschneidereit/66-fix-osx-arm64
#66 loosen tolerance for comparing memory consumption
2 parents 6868f0c + b414c55 commit bf5910e

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
]
2424
python-version: [
2525
'3.8',
26-
'3.9',
27-
'3.10'
26+
'3.10',
27+
'3.12'
2828
]
2929

3030
steps:

dev-environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ dependencies:
2828
- numpy
2929
- pandas
3030
# Developer tools
31+
- assertpy
3132
- autopep8
3233
- black
3334
- build
3435
- flake8
35-
- flake8-typing-imports
3636
- isort
3737
- pytest
3838
- pytest-cov
@@ -42,5 +42,6 @@ dependencies:
4242
- pip:
4343
- git+https://github.com/ninia/jep.git@cfca63f8b3398daa6d2685428660dc4b2bfab67d
4444
- flake8-pyproject
45+
- flake8-typing-imports
4546
- validate-pyproject[all]
4647
- -e .

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ dependencies = [
3939
[project.optional-dependencies]
4040
# NB: Keep this in sync with dev-environment.yml!
4141
dev = [
42+
"assertpy",
4243
"autopep8",
4344
"black",
4445
"build",

tests/it/java_heap.py

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

5+
from assertpy import assert_that
6+
57
import scyjava
68

79
mb_initial = 50 # initial MB of memory to snarf up
10+
mb_tolerance = 10 # ceiling of expected MB in use
811

912
scyjava.config.set_heap_min(mb=mb_initial)
1013
scyjava.config.set_heap_max(gb=1)
@@ -18,17 +21,15 @@
1821
mb_total = scyjava.memory_total() // 1024 // 1024
1922
mb_used = scyjava.memory_used() // 1024 // 1024
2023

21-
# Used memory should be less than the current memory total,
22-
# which should be less than the maximum heap size.
23-
assert mb_used <= mb_total <= mb_max, f"{mb_used=} {mb_total=} {mb_max=}"
24-
25-
# The maximum heap size should be approximately 1 GB.
26-
assert 900 <= mb_max <= 1024, f"{mb_max=}"
27-
28-
# Most of that memory should still be free; i.e.,
29-
# we should not be using more than a few MB yet.
30-
assert mb_used <= 5, f"{mb_used=}"
31-
32-
# The total MB available to Java at this moment
33-
# should be close to our requested initial amount.
34-
assert abs(mb_total - mb_initial) < 5, f"{mb_total=} {mb_initial=}"
24+
assert_that(
25+
mb_used, "Used memory should be less than the current memory total"
26+
).is_less_than_or_equal_to(mb_total)
27+
assert_that(
28+
mb_total, "current memory total should be less than maximum memory"
29+
).is_less_than_or_equal_to(mb_max)
30+
assert_that(mb_max, "maximum heap size should be approx. 1 GB").is_between(900, 1024)
31+
32+
assert_that(mb_used, "most memory should be available").is_less_than(mb_tolerance)
33+
assert_that(mb_total, "total memory should be close to initial").is_close_to(
34+
mb_initial, tolerance=mb_tolerance
35+
)

0 commit comments

Comments
 (0)
0