Skip to content

Commit 6dd9817

Browse files
committed
Add additional tests
1 parent 6105865 commit 6dd9817

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

tests/test_cache_fileexecutor_serial.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def list_files_in_working_directory():
2727
return os.listdir(os.getcwd())
2828

2929

30+
def get_error(a):
31+
raise ValueError(a)
32+
33+
3034
@unittest.skipIf(
3135
skip_h5py_test, "h5py is not installed, so the h5py tests are skipped."
3236
)
@@ -68,6 +72,15 @@ def test_executor_working_directory(self):
6872
fs1 = exe.submit(list_files_in_working_directory)
6973
self.assertEqual(fs1.result(), os.listdir(cwd))
7074

75+
def test_executor_error(self):
76+
cwd = os.path.join(os.path.dirname(__file__), "executables")
77+
with FileExecutor(
78+
resource_dict={"cwd": cwd}, execute_function=execute_in_subprocess
79+
) as exe:
80+
fs1 = exe.submit(get_error, a=1)
81+
with self.assertRaises(ValueError):
82+
fs1.result()
83+
7184
def test_executor_function(self):
7285
fs1 = Future()
7386
q = Queue()

tests/test_standalone_hdf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ def test_hdf_queue_id(self):
104104
self.assertFalse(no_error)
105105
self.assertIsNone(output)
106106

107+
def test_hdf_error(self):
108+
cache_directory = os.path.abspath("cache")
109+
os.makedirs(cache_directory, exist_ok=True)
110+
file_name = os.path.join(cache_directory, "test_error.h5")
111+
error = ValueError()
112+
dump(
113+
file_name=file_name,
114+
data_dict={"error": error},
115+
)
116+
flag, no_error, output = get_output(file_name=file_name)
117+
self.assertTrue(get_runtime(file_name=file_name) == 0.0)
118+
self.assertTrue(flag)
119+
self.assertFalse(no_error)
120+
self.assertTrue(isinstance(output, error.__class__))
121+
107122
def tearDown(self):
108123
if os.path.exists("cache"):
109124
shutil.rmtree("cache")

0 commit comments

Comments
 (0)