Skip to content

Commit d740d06

Browse files
committed
Add more tests
1 parent 6eb096f commit d740d06

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_local_executor.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import importlib.util
33
from queue import Queue
44
from time import sleep
5+
import shutil
56
import unittest
67

78
import numpy as np
@@ -16,6 +17,12 @@
1617
from executorlib.standalone.interactive.backend import call_funct
1718
from executorlib.standalone.serialize import cloudpickle_register
1819

20+
try:
21+
import h5py
22+
23+
skip_h5py_test = False
24+
except ImportError:
25+
skip_h5py_test = True
1926

2027
skip_mpi4py_test = importlib.util.find_spec("mpi4py") is None
2128

@@ -473,3 +480,27 @@ def test_execute_task_parallel(self):
473480
)
474481
self.assertEqual(f.result(), [np.array(4), np.array(4)])
475482
q.join()
483+
484+
485+
class TestFuturePoolCache(unittest.TestCase):
486+
def tearDown(self):
487+
shutil.rmtree("./cache")
488+
489+
@unittest.skipIf(
490+
skip_h5py_test, "h5py is not installed, so the h5py tests are skipped."
491+
)
492+
def test_execute_task_cache(self):
493+
f = Future()
494+
q = Queue()
495+
q.put({"fn": calc, "args": (), "kwargs": {"i": 1}, "future": f})
496+
q.put({"shutdown": True, "wait": True})
497+
cloudpickle_register(ind=1)
498+
execute_parallel_tasks(
499+
future_queue=q,
500+
cores=1,
501+
openmpi_oversubscribe=False,
502+
spawner=MpiExecSpawner,
503+
cache_directory="./cache",
504+
)
505+
self.assertEqual(f.result(), 1)
506+
q.join()

0 commit comments

Comments
 (0)