test_h5o.py 522 B

1234567891011121314151617181920
  1. import pytest
  2. from .common import TestCase, make_name
  3. from h5py import File
  4. class SampleException(Exception):
  5. pass
  6. def throwing(name, obj):
  7. raise SampleException(f"throwing exception for {name} {obj}")
  8. class TestVisit(TestCase):
  9. def test_visit(self):
  10. fname = self.mktemp()
  11. fid = File(fname, 'w')
  12. fid.create_dataset(make_name(), (100,), dtype='uint8')
  13. with pytest.raises(SampleException, match='throwing exception'):
  14. fid.visititems(throwing)
  15. fid.close()