[h5py] 405/455: Port serialization and commit tests to new system

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:55 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 63a47c83b7ecd18c18e59df6d173344fece53204
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Wed Feb 10 06:43:38 2010 +0000

    Port serialization and commit tests to new system
---
 h5py/tests/low/test_h5t.py | 25 ++++++++++++++
 h5py/tests/test_h5t.py     | 84 ----------------------------------------------
 2 files changed, 25 insertions(+), 84 deletions(-)

diff --git a/h5py/tests/low/test_h5t.py b/h5py/tests/low/test_h5t.py
index f7b1274..45decdb 100644
--- a/h5py/tests/low/test_h5t.py
+++ b/h5py/tests/low/test_h5t.py
@@ -87,6 +87,31 @@ class TestTypeID(Base):
         """ (H5T) get_class() """
         self.assertEqual(h5t.STD_I32LE.get_class(), h5t.INTEGER)
 
+class TestEncodeDecode(Base):
+
+    def setUp(self):
+        self.tid = h5t.STD_I32LE.copy()
+
+    def tearDown(self):
+        del self.tid
+
+    @tests.require(api=18)
+    def test_ed(self):
+        """ (H5T) Encode/decode round trip """
+        enc = self.tid.encode()
+        self.assertIsInstance(enc, str)
+        dec = h5t.decode(enc)
+        self.assertEqual(self.tid, dec)
+
+    @tests.require(api=18)
+    def test_pickle(self):
+        """ (H5T) Encode/decode round trip via pickling """
+        import pickle
+        pkl = pickle.dumps(self.tid)
+        dec = pickle.loads(pkl)
+        self.assertEqual(self.tid, dec)
+
+
 class TestFloat(Base):
 
     @tests.require(hasattr(np, 'float128'))
diff --git a/h5py/tests/test_h5t.py b/h5py/tests/test_h5t.py
index 85a0cfe..22437cd 100644
--- a/h5py/tests/test_h5t.py
+++ b/h5py/tests/test_h5t.py
@@ -45,65 +45,8 @@ class BaseTypeMixin(object):
     def tearDown(self):
         res.clear()
 
-    ODDBALL_TYPE = h5t.create(h5t.OPAQUE, 72)
-
-    # --- The following attributes and methods MUST be overridden ---
-
-    CLASSCODE = -1
-
-    def get_example_type(self):
-        """ Override this method to provide a dynamically-created example
-         type, which will be used to test common TypeID operations.
-        """
-        raise NotImplementedError("!")
-
-    def get_example_encoding(self):
-        """ Override this method to provide a known-good serialized example
-        of the example type above.  Only called with 1.8 API.
-        """
-        raise NotImplementedError("!")
-
-    # --- End required attributes and methods ---
-
-    @api_18
-    def test_serialize(self):
-        """ Generic subtype serialization test
-        """
-        # Round-trip serialization
-        htype = self.get_example_type()
-        htype2 = h5t.decode(htype.encode())
-        self.assertEqual(htype, htype2)
-
-        # Deserialization of known buffer
-        ser = self.get_example_encoding()
-        htype3 = h5t.decode(ser)
-        self.assertEqual(htype, htype2)
-
-        # Pickling
-        pkl = cPickle.dumps(htype)
-        htype4 = cPickle.loads(pkl)
-        self.assertEqual(htype, htype4)
-
-    def test_commit(self):
-        """ Generic subtype commit test
-        """
-        fid = h5f.create(res.get_name())
-        htype = self.get_example_type()
-        self.assert_(not htype.committed())
-        htype.commit(fid, "name")
-        self.assert_(htype.committed())
-        htype2 = h5t.open(fid, "name")
-        self.assertEqual(htype, htype2)
-
 class TestInteger(TestCasePlus, BaseTypeMixin):
 
-    CLASSCODE = h5t.INTEGER
-
-    def get_example_type(self):
-        return h5t.STD_I32LE.copy()
-    def get_example_encoding(self):
-        return mkstr([3, 0, 16, 8, 0, 0, 4, 0, 0, 0, 0, 0, 32, 0])
-
     def test_set_get_order_sign(self):
         
         htype = h5t.STD_I32LE.copy()
@@ -117,34 +60,8 @@ class TestInteger(TestCasePlus, BaseTypeMixin):
         self.assertEqual(htype.get_order(), h5t.ORDER_BE)
         self.assertEqual(htype.get_sign(), h5t.SGN_NONE)
 
-class TestFloat(TestCasePlus, BaseTypeMixin):
-
-    CLASSCODE = h5t.FLOAT   
-
-    def get_example_type(self):
-        return h5t.IEEE_F32LE.copy()
-    def get_example_encoding(self):
-        return mkstr([3, 0, 17, 32, 31, 0, 4, 0, 0, 0, 0, 0, 
-                      32, 0, 23, 8, 0, 23, 127, 0, 0, 0])
-
-class TestString(TestCasePlus, BaseTypeMixin):
-
-    CLASSCODE = h5t.STRING
-
-    def get_example_type(self):
-        return h5t.C_S1.copy()
-    def get_example_encoding(self):
-        return mkstr([3, 0, 19, 0, 0, 0, 1, 0, 0, 0])
-
 class TestOpaque(TestCasePlus, BaseTypeMixin):
 
-    CLASSCODE = h5t.OPAQUE
-
-    def get_example_type(self):
-        return h5t.create(h5t.OPAQUE, 31)
-    def get_example_encoding(self):
-        return mkstr([3, 0, 21, 0, 0, 0, 31, 0, 0, 0])
-
     def test_setget_tag(self):
         htype = h5t.create(h5t.OPAQUE, 40)
         htype.set_tag("FOOBAR")
@@ -185,7 +102,6 @@ class TestH5T(TestCasePlus):
         self.assert_(htype.detect_class(h5t.OPAQUE))
         self.assert_(not htype.detect_class(h5t.ARRAY))
 
-
         
     def test_array(self):
         """ Test all array-specific features """

-- 
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