[python-hdf5storage] 90/152: Added write readback tests for dicts.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:37 UTC 2016


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

ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.

commit 3cb8514dd8381d0fe3e2051f803f066679fb96ea
Author: Freja Nordsiek <fnordsie at gmail.com>
Date:   Sun Feb 2 23:37:08 2014 -0500

    Added write readback tests for dicts.
---
 tests/test_write_readback.py | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/test_write_readback.py b/tests/test_write_readback.py
index c6d3355..a19560c 100644
--- a/tests/test_write_readback.py
+++ b/tests/test_write_readback.py
@@ -41,6 +41,11 @@ class TestPythonMatlabFormat(object):
         self.max_posix_path_lengths = 17
         self.object_subarray_dimensions = 2
         self.max_object_subarray_axis_length = 5
+        self.min_dict_keys = 4
+        self.max_dict_keys = 12
+        self.max_dict_key_length = 10
+        self.dict_value_subarray_dimensions = 2
+        self.max_dict_value_subarray_axis_length = 5
 
     def random_str_ascii(self, length):
         # Makes a random ASCII str of the specified length.
@@ -132,6 +137,18 @@ class TestPythonMatlabFormat(object):
                             self.max_string_length)))
             return data
 
+    def random_dict(self):
+        # Makes a random dict (random number of randomized keys with
+        # random numpy arrays as values).
+        data = dict()
+        for i in range(0, random.randint(self.min_dict_keys, \
+                self.max_dict_keys)):
+            data[self.random_str_ascii(self.max_dict_key_length)] = \
+                self.random_numpy(self.random_numpy_shape( \
+                self.dict_value_subarray_dimensions, \
+                self.max_dict_value_subarray_axis_length), \
+                dtype=random.choice(self.dtypes))
+
     def random_name(self):
         # Makes a random POSIX path of a random depth.
         depth = random.randint(1, self.max_posix_path_depth)
@@ -337,6 +354,12 @@ class TestPythonMatlabFormat(object):
         for tp in (list, tuple, set, frozenset, collections.deque):
             yield self.check_python_collection, tp
 
+    def test_dict(self):
+        data = self.random_dict()
+        out = self.write_readback(data, self.random_name(),
+                                  self.options)
+        self.assert_equal(out, data)
+
 
 class TestPythonFormat(TestPythonMatlabFormat):
     def __init__(self):

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



More information about the debian-science-commits mailing list