Skip to content

Commit

Permalink
Add additional tests to improve coverage (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen authored Oct 29, 2024
1 parent 4ca7502 commit b41acba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/test_cache_executor_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ def test_executor_function_dependence_args(self):
q.put({"shutdown": True, "wait": True})
process.join()

def test_execute_in_subprocess_errors(self):
with self.assertRaises(ValueError):
execute_in_subprocess(command=[], config_directory="test")
with self.assertRaises(ValueError):
execute_in_subprocess(command=[], backend="flux")

def tearDown(self):
if os.path.exists("cache"):
shutil.rmtree("cache")
11 changes: 10 additions & 1 deletion tests/test_cache_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


try:
from executorlib.standalone.hdf import dump, load
from executorlib.standalone.hdf import dump, load, get_output

skip_h5py_test = False
except ImportError:
Expand Down Expand Up @@ -33,6 +33,9 @@ def test_hdf_mixed(self):
self.assertTrue("fn" in data_dict.keys())
self.assertEqual(data_dict["args"], [a])
self.assertEqual(data_dict["kwargs"], {"b": b})
flag, output = get_output(file_name=file_name)
self.assertFalse(flag)
self.assertIsNone(output)

def test_hdf_args(self):
cache_directory = os.path.abspath("cache")
Expand All @@ -45,6 +48,9 @@ def test_hdf_args(self):
self.assertTrue("fn" in data_dict.keys())
self.assertEqual(data_dict["args"], [a, b])
self.assertEqual(data_dict["kwargs"], {})
flag, output = get_output(file_name=file_name)
self.assertFalse(flag)
self.assertIsNone(output)

def test_hdf_kwargs(self):
cache_directory = os.path.abspath("cache")
Expand All @@ -60,6 +66,9 @@ def test_hdf_kwargs(self):
self.assertTrue("fn" in data_dict.keys())
self.assertEqual(data_dict["args"], ())
self.assertEqual(data_dict["kwargs"], {"a": a, "b": b})
flag, output = get_output(file_name=file_name)
self.assertFalse(flag)
self.assertIsNone(output)

def tearDown(self):
if os.path.exists("cache"):
Expand Down
18 changes: 17 additions & 1 deletion tests/test_executor_backend_mpi_noblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,27 @@ def resource_dict(resource_dict):


class TestExecutorBackend(unittest.TestCase):
def test_meta_executor_serial(self):
def test_meta_executor_serial_with_dependencies(self):
with Executor(
max_cores=2,
backend="local",
block_allocation=False,
disable_dependencies=True,
) as exe:
cloudpickle_register(ind=1)
fs_1 = exe.submit(calc, 1)
fs_2 = exe.submit(calc, 2)
self.assertEqual(fs_1.result(), 1)
self.assertEqual(fs_2.result(), 2)
self.assertTrue(fs_1.done())
self.assertTrue(fs_2.done())

def test_meta_executor_serial_without_dependencies(self):
with Executor(
max_cores=2,
backend="local",
block_allocation=False,
disable_dependencies=False,
) as exe:
cloudpickle_register(ind=1)
fs_1 = exe.submit(calc, 1)
Expand Down

0 comments on commit b41acba

Please sign in to comment.