test_h5o.py 508 B

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