test_objects.py 911 B

123456789101112131415161718192021222324252627282930313233343536
  1. # This file is part of h5py, a Python interface to the HDF5 library.
  2. #
  3. # http://www.h5py.org
  4. #
  5. # Copyright 2008-2013 Andrew Collette and contributors
  6. #
  7. # License: Standard 3-clause BSD; see "license.txt" for full license terms
  8. # and contributor agreement.
  9. from h5py import _objects as o
  10. from .common import TestCase
  11. class TestObjects(TestCase):
  12. def test_invalid(self):
  13. # Check for segfault on close
  14. oid = o.ObjectID(0)
  15. del oid
  16. oid = o.ObjectID(1)
  17. del oid
  18. def test_equality(self):
  19. # Identifier-based equality
  20. oid1 = o.ObjectID(42)
  21. oid2 = o.ObjectID(42)
  22. oid3 = o.ObjectID(43)
  23. self.assertEqual(oid1, oid2)
  24. self.assertNotEqual(oid1, oid3)
  25. def test_hash(self):
  26. # Default objects are not hashable
  27. oid = o.ObjectID(42)
  28. with self.assertRaises(TypeError):
  29. hash(oid)