[h5py] 136/455: Add missing test module

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.

commit e670de6ecb7be3da56acf2976148574165cb69aa
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Tue Oct 14 20:47:42 2008 +0000

    Add missing test module
---
 h5py/tests/test_utils.py | 81 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/h5py/tests/test_utils.py b/h5py/tests/test_utils.py
new file mode 100644
index 0000000..1636a0f
--- /dev/null
+++ b/h5py/tests/test_utils.py
@@ -0,0 +1,81 @@
+#+
+# 
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+# 
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD  (See LICENSE.txt for full license)
+# 
+# $Date$
+# 
+#-
+import sys
+import numpy
+
+from common import HDF5TestCase, api_18
+
+from h5py import *
+from h5py import utils
+from h5py.h5 import H5Error
+
+class TestUtils(HDF5TestCase):
+
+    def test_check_read(self):
+        """ Check if it's possible to read from the NumPy array """
+
+        carr = numpy.ones((10,10), order='C')
+        farr = numpy.ones((10,10), order='F')
+        oarr = numpy.ones((10,10), order='C')
+        oarr.strides = (0,1)
+
+        utils.check_numpy_read(carr)
+        self.assertRaises(TypeError, utils.check_numpy_read, farr)
+        self.assertRaises(TypeError, utils.check_numpy_read, oarr)
+
+        s_space = h5s.create_simple((5,5))
+        m_space = h5s.create_simple((10,10))
+        l_space = h5s.create_simple((12,12))
+
+        utils.check_numpy_read(carr, m_space.id)
+        utils.check_numpy_read(carr, l_space.id)
+        self.assertRaises(TypeError, utils.check_numpy_read, carr, s_space.id)
+
+        # This should not matter for read
+        carr.flags['WRITEABLE'] = False
+        utils.check_numpy_read(carr)
+
+    def test_check_write(self):
+        """ Check if it's possible to write to the NumPy array """
+
+        carr = numpy.ones((10,10), order='C')
+        farr = numpy.ones((10,10), order='F')
+        oarr = numpy.ones((10,10), order='C')
+        oarr.strides = (0,1)
+
+        utils.check_numpy_write(carr)
+        self.assertRaises(TypeError, utils.check_numpy_write, farr)
+        self.assertRaises(TypeError, utils.check_numpy_write, oarr)
+
+        s_space = h5s.create_simple((5,5))
+        m_space = h5s.create_simple((10,10))
+        l_space = h5s.create_simple((12,12))
+
+        utils.check_numpy_write(carr, s_space.id)
+        utils.check_numpy_write(carr, m_space.id)
+        self.assertRaises(TypeError, utils.check_numpy_write, carr, l_space.id)
+
+        # This should matter now
+        carr.flags['WRITEABLE'] = False
+        self.assertRaises(TypeError, utils.check_numpy_write, carr)
+
+    def test_emalloc(self):
+        
+        utils._test_emalloc(1024)
+        utils._test_emalloc(0)
+        self.assertRaises(MemoryError, utils._test_emalloc, sys.maxint)
+
+
+
+
+
+

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git



More information about the debian-science-commits mailing list