3RNN/Lib/site-packages/h5py/tests/test_h5o.py

22 lines
508 B
Python
Raw Permalink Normal View History

2024-05-26 19:49:15 +02:00
import pytest
from .common import TestCase
from h5py import File
class SampleException(Exception):
pass
def throwing(name, obj):
print(name, obj)
raise SampleException("throwing exception")
class TestVisit(TestCase):
def test_visit(self):
fname = self.mktemp()
fid = File(fname, 'w')
fid.create_dataset('foo', (100,), dtype='uint8')
with pytest.raises(SampleException, match='throwing exception'):
fid.visititems(throwing)
fid.close()