Skip to content

Commit

Permalink
Properly skip folder tests with h5py
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Apr 23, 2024
1 parent 04f715c commit 407ffb1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
12 changes: 6 additions & 6 deletions test/hl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,22 @@ def getTestFileName(basename, subfolder=None):

if config.get("use_h5py"):
filename = "out"
if not op.isdir(filename):
if not os.path.isdir(filename):
os.mkdir(filename)
if subfolder:
filename = op.join(filename, subfolder)
if not op.isdir(filename):
filename = os.path.join(filename, subfolder)
if not os.path.isdir(filename):
os.mkdir(filename)
filename = op.join(filename, f"{basename}.h5")
filename = os.path.join(filename, f"{basename}.h5")
else:
if "H5PYD_TEST_FOLDER" in os.environ:
filename = os.environ["H5PYD_TEST_FOLDER"]
else:
# default to the root folder
filename = "/"
if subfolder:
filename = op.join(filename, subfolder)
filename = op.join(filename, f"{basename}.h5")
filename = os.path.join(filename, subfolder)
filename = os.path.join(filename, f"{basename}.h5")
return filename


Expand Down
27 changes: 12 additions & 15 deletions test/hl/test_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
class TestFolders(TestCase):

def test_list(self):
if config.get("use_h5py"):
# Folders not supported for h5py
return

# loglevel = logging.DEBUG
# logging.basicConfig( format='%(asctime)s %(message)s', level=loglevel)
test_domain = self.getFileName("folder_test")
Expand All @@ -34,11 +38,6 @@ def test_list(self):
# create test file if not present.
# on first run, this may take a minute before it is visible as a folder item
f = h5py.File(filepath, mode='a')
if config.get("use_h5py"):
# Folders not supported for h5py
f.close()
return

self.assertTrue(f.id.id is not None)

f.close()
Expand Down Expand Up @@ -170,17 +169,15 @@ def test_list(self):
f.close()

def test_create_folder(self):
if config.get("use_h5py"):
# Folders not supported for h5py
return

empty = self.getFileName("empty")
empty_path = self.getPathFromDomain(empty)

print("empty_path", empty_path)

f = h5py.File(empty_path, mode='a')
self.assertTrue(f.id.id is not None)
if config.get("use_h5py"):
# Folders not supported for h5py
f.close()
return

f.close()

Expand All @@ -195,15 +192,15 @@ def test_create_folder(self):
d.close()

def test_root_folder(self):
if config.get("use_h5py"):
# Folders not supported for h5py
return

test_domain = self.getFileName("folder_test")

filepath = self.getPathFromDomain(test_domain)
f = h5py.File(filepath, mode='a')
self.assertTrue(f.id.id is not None)
if config.get("use_h5py"):
# Folders not supported for h5py
f.close()
return

f.close()

Expand Down

0 comments on commit 407ffb1

Please sign in to comment.