Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/PyMca5/tests/HDF5UtilsTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
import datetime
import h5py
import sys
try:
import multiprocessing
except Exception:
pass

from PyMca5.PyMcaIO import HDF5Utils

def _pass_through():
return 0

def _cause_segfault(*args, **kwargs):
import ctypes
Expand Down Expand Up @@ -47,9 +45,19 @@ def testHdf5GroupKeys(self):
self.assertEqual(HDF5Utils.get_hdf5_group_keys(filename), names)
self.assertEqual(HDF5Utils.safe_hdf5_group_keys(filename), names)

@unittest.skipIf("multiprocessing" not in sys.modules, "skipped multiprocessing missing")
def testSegFault(self):
self.assertEqual(_safe_cause_segfault(default=123), 123)
# Verify that run_in_subprocess can be used
try:
result = HDF5Utils.run_in_subprocess(_pass_through, default=123)
except Exception:
if not getattr(sys, "frozen", False):
raise
self.skipTest("multiprocessing does not work for the current frozen binary")
self.assertEqual(result, 0)

# Check that run_in_subprocess works as intended when the function segfaults
result = HDF5Utils.run_in_subprocess(_cause_segfault, default=123)
self.assertEqual(result, 123)

def testHdf5GroupSortByName(self):
filename = os.path.join(self.path, "test.h5")
Expand Down