test_h5.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 h5
  10. from .common import TestCase
  11. def fixnames():
  12. cfg = h5.get_config()
  13. cfg.complex_names = ('r','i')
  14. class TestH5(TestCase):
  15. def test_config(self):
  16. cfg = h5.get_config()
  17. self.assertIsInstance(cfg, h5.H5PYConfig)
  18. cfg2 = h5.get_config()
  19. self.assertIs(cfg, cfg2)
  20. def test_cnames_get(self):
  21. cfg = h5.get_config()
  22. self.assertEqual(cfg.complex_names, ('r','i'))
  23. def test_cnames_set(self):
  24. self.addCleanup(fixnames)
  25. cfg = h5.get_config()
  26. cfg.complex_names = ('q','x')
  27. self.assertEqual(cfg.complex_names, ('q','x'))
  28. def test_cnames_set_exc(self):
  29. self.addCleanup(fixnames)
  30. cfg = h5.get_config()
  31. with self.assertRaises(TypeError):
  32. cfg.complex_names = ('q','i','v')
  33. self.assertEqual(cfg.complex_names, ('r','i'))
  34. def test_repr(self):
  35. cfg = h5.get_config()
  36. repr(cfg)