test_h5pl.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # This file is part of h5py, a Python interface to the HDF5 library.
  2. #
  3. # http://www.h5py.org
  4. #
  5. # Copyright 2008-2019 Andrew Collette and contributors
  6. #
  7. # License: Standard 3-clause BSD; see "license.txt" for full license terms
  8. # and contributor agreement.
  9. import pytest
  10. import h5py
  11. from h5py import h5pl
  12. from h5py.tests.common import insubprocess, subproc_env
  13. # pytestmark is a special name - the skipif marker applies to the whole file
  14. pytestmark = pytest.mark.skipif(
  15. h5py.version.hdf5_version_tuple < (1, 10, 1), reason='HDF5 1.10.1+ required'
  16. )
  17. @pytest.mark.mpi_skip
  18. @insubprocess
  19. @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
  20. def test_default(request):
  21. assert h5pl.size() == 1
  22. assert h5pl.get(0) == b'h5py_plugin_test'
  23. @pytest.mark.mpi_skip
  24. @insubprocess
  25. @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
  26. def test_append(request):
  27. h5pl.append(b'/opt/hdf5/vendor-plugin')
  28. assert h5pl.size() == 2
  29. assert h5pl.get(0) == b'h5py_plugin_test'
  30. assert h5pl.get(1) == b'/opt/hdf5/vendor-plugin'
  31. @pytest.mark.mpi_skip
  32. @insubprocess
  33. @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
  34. def test_prepend(request):
  35. h5pl.prepend(b'/opt/hdf5/vendor-plugin')
  36. assert h5pl.size() == 2
  37. assert h5pl.get(0) == b'/opt/hdf5/vendor-plugin'
  38. assert h5pl.get(1) == b'h5py_plugin_test'
  39. @pytest.mark.mpi_skip
  40. @insubprocess
  41. @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
  42. def test_insert(request):
  43. h5pl.insert(b'/opt/hdf5/vendor-plugin', 0)
  44. assert h5pl.size() == 2
  45. assert h5pl.get(0) == b'/opt/hdf5/vendor-plugin'
  46. assert h5pl.get(1) == b'h5py_plugin_test'
  47. @pytest.mark.mpi_skip
  48. @insubprocess
  49. @subproc_env({'HDF5_PLUGIN_PATH': 'h5py_plugin_test'})
  50. def test_replace(request):
  51. h5pl.replace(b'/opt/hdf5/vendor-plugin', 0)
  52. assert h5pl.size() == 1
  53. assert h5pl.get(0) == b'/opt/hdf5/vendor-plugin'
  54. @pytest.mark.mpi_skip
  55. @insubprocess
  56. def test_remove(request):
  57. h5pl.remove(0)
  58. assert h5pl.size() == 0