Skip to content

Commit 80a9668

Browse files
committed
Add a couple unit tests that should take long enough that heartbeats will actually happen.
1 parent d1a1579 commit 80a9668

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/test_gridmap.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from __future__ import print_function, unicode_literals
2424

2525
import logging
26+
from time import sleep
2627

2728
import gridmap
2829
from gridmap import Job, process_jobs, grid_map
@@ -37,6 +38,15 @@
3738
logger = logging.getLogger(__name__)
3839
logger.debug('Path to gridmap: %s', gridmap)
3940

41+
42+
def compute_factorial_slow(n):
43+
sleep(100)
44+
ret = 1
45+
for i in range(n):
46+
ret = ret * (i + 1)
47+
return ret
48+
49+
4050
def compute_factorial(n):
4151
ret = 1
4252
for i in range(n):
@@ -51,6 +61,13 @@ def test_map():
5161
eq_(expected, outputs)
5262

5363

64+
def test_map_slow():
65+
inputs = [1, 2, 4, 8, 16]
66+
expected = list(map(compute_factorial_slow, inputs))
67+
outputs = grid_map(compute_factorial_slow, inputs, quiet=False)
68+
eq_(expected, outputs)
69+
70+
5471
def make_jobs(inputvec, function):
5572
# create empty job vector
5673
jobs = []
@@ -71,3 +88,11 @@ def test_process_jobs():
7188
function_jobs = make_jobs(inputs, compute_factorial)
7289
outputs = process_jobs(function_jobs, quiet=False)
7390
eq_(expected, outputs)
91+
92+
93+
def test_process_jobs_slow():
94+
inputs = [1, 2, 4, 8, 16]
95+
expected = list(map(compute_factorial_slow, inputs))
96+
function_jobs = make_jobs(inputs, compute_factorial_slow)
97+
outputs = process_jobs(function_jobs, quiet=False)
98+
eq_(expected, outputs)

0 commit comments

Comments
 (0)