diff options
author | Max Sperlich <max.sperlich@livingsocial.com> | 2013-12-08 21:15:00 -0500 |
---|---|---|
committer | Max Sperlich <max.sperlich@livingsocial.com> | 2013-12-08 21:18:03 -0500 |
commit | 161ca8ff732ed58613b9bdcb2f1dcad7178a76c5 (patch) | |
tree | 34197a2c2491e14025ee305769684ed0e1ab9724 /numpy/lib/tests | |
parent | aa2443af6e6de74edff19757ba1c827b69f7640f (diff) | |
download | numpy-161ca8ff732ed58613b9bdcb2f1dcad7178a76c5.tar.gz |
STY: pep8
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_format.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index f7df8b11b..b5b6ef885 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -410,14 +410,14 @@ record_arrays = [ np.array(NbufferT, dtype=np.dtype(Ndescr).newbyteorder('>')), ] + #BytesIO that returns fewer bytes than requested class BytesIORandomSize(BytesIO): def read(self, size=None): from random import randint - size = randint(min(512,size), size) - data = super(BytesIORandomSize, self).read(size) - assert len(data) <= size - return data + size = randint(min(512, size), size) + return super(BytesIORandomSize, self).read(size) + def roundtrip(arr): f = BytesIO() @@ -426,6 +426,7 @@ def roundtrip(arr): arr2 = format.read_array(f2) return arr2 + def roundtrip_randsize(arr): f = BytesIO() format.write_array(f, arr) @@ -433,6 +434,7 @@ def roundtrip_randsize(arr): arr2 = format.read_array(f2) return arr2 + def roundtrip_truncated(arr): f = BytesIO() format.write_array(f, arr) @@ -451,15 +453,18 @@ def test_roundtrip(): arr2 = roundtrip(arr) yield assert_array_equal, arr, arr2 + def test_roundtrip_randsize(): for arr in basic_arrays[2:] + record_arrays: arr2 = roundtrip_randsize(arr) yield assert_array_equal, arr, arr2 + def test_roundtrip_truncated(): for arr in basic_arrays: if arr.dtype != object: - assert_raises(ValueError, roundtrip_truncated, arr) + yield assert_raises, ValueError, roundtrip_truncated, arr + def test_long_str(): # check items larger than internal buffer size, gh-4027 @@ -467,6 +472,7 @@ def test_long_str(): long_str_arr2 = roundtrip(long_str_arr) assert_array_equal(long_str_arr, long_str_arr2) + @dec.slow def test_memmap_roundtrip(): # XXX: test crashes nose on windows. Fix this |