74 lines
2.9 KiB
Diff
74 lines
2.9 KiB
Diff
From eea4cbc6a4b6333182c8d9b43276f8269c49d980 Mon Sep 17 00:00:00 2001
|
|
From: Aleksandar Jelenak <ajelenak@hdfgroup.org>
|
|
Date: Wed, 3 Apr 2024 11:29:22 -0400
|
|
Subject: [PATCH] Add page buffer and fix file locking tests
|
|
|
|
---
|
|
h5py/tests/test_file.py | 36 ++++++++++++++++++++++++++++++++++--
|
|
1 file changed, 34 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/h5py/tests/test_file.py b/h5py/tests/test_file.py
|
|
index 1aa38731..0ceddc37 100644
|
|
--- a/h5py/tests/test_file.py
|
|
+++ b/h5py/tests/test_file.py
|
|
@@ -213,6 +213,8 @@ class TestPageBuffering(TestCase):
|
|
fapl = f.id.get_access_plist()
|
|
self.assertEqual(fapl.get_page_buffer_size(), (pbs, mm, mr))
|
|
|
|
+ @pytest.mark.skipif(h5py.version.hdf5_version_tuple > (1, 14, 3),
|
|
+ reason='Requires HDF5 <= 1.14.3')
|
|
def test_too_small_pbs(self):
|
|
"""Page buffer size must be greater than file space page size."""
|
|
fname = self.mktemp()
|
|
@@ -222,6 +224,30 @@ class TestPageBuffering(TestCase):
|
|
with self.assertRaises(OSError):
|
|
File(fname, mode="r", page_buf_size=fsp-1)
|
|
|
|
+ @pytest.mark.skipif(h5py.version.hdf5_version_tuple < (1, 14, 4),
|
|
+ reason='Requires HDF5 >= 1.14.4')
|
|
+ def test_open_nonpage_pbs(self):
|
|
+ """Open non-PAGE file with page buffer set."""
|
|
+ fname = self.mktemp()
|
|
+ fsp = 16 * 1024
|
|
+ with File(fname, mode='w'):
|
|
+ pass
|
|
+ with File(fname, mode='r', page_buf_size=fsp) as f:
|
|
+ fapl = f.id.get_access_plist()
|
|
+ assert fapl.get_page_buffer_size()[0] == 0
|
|
+
|
|
+ @pytest.mark.skipif(h5py.version.hdf5_version_tuple < (1, 14, 4),
|
|
+ reason='Requires HDF5 >= 1.14.4')
|
|
+ def test_smaller_pbs(self):
|
|
+ """Adjust page buffer size automatically when smaller than file page."""
|
|
+ fname = self.mktemp()
|
|
+ fsp = 16 * 1024
|
|
+ with File(fname, mode='w', fs_strategy='page', fs_page_size=fsp):
|
|
+ pass
|
|
+ with File(fname, mode='r', page_buf_size=fsp-100) as f:
|
|
+ fapl = f.id.get_access_plist()
|
|
+ assert fapl.get_page_buffer_size()[0] == fsp
|
|
+
|
|
def test_actual_pbs(self):
|
|
"""Verify actual page buffer size."""
|
|
fname = self.mktemp()
|
|
@@ -923,8 +949,14 @@ class TestFileLocking:
|
|
with h5py.File(fname, mode="r", locking=True) as h5f_read:
|
|
pass
|
|
|
|
- with h5py.File(fname, mode="r", locking='best-effort') as h5f_read:
|
|
- pass
|
|
+ if h5py.version.hdf5_version_tuple < (1, 14, 4):
|
|
+ with h5py.File(fname, mode="r", locking='best-effort') as h5f_read:
|
|
+ pass
|
|
+ else:
|
|
+ with pytest.raises(OSError):
|
|
+ with h5py.File(fname, mode="r", locking='best-effort') as h5f_read:
|
|
+ pass
|
|
+
|
|
|
|
def test_unsupported_locking(self, tmp_path):
|
|
"""Test with erroneous file locking value"""
|
|
--
|
|
2.27.0
|
|
|