diff options
author | Pauli Virtanen <pav@iki.fi> | 2015-04-17 14:29:43 +0300 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2015-04-18 22:06:07 +0300 |
commit | a2bd3a7eabfe053d6d16a2130fdcad9e5211f6bb (patch) | |
tree | 4de542b4f706b39a2794f58cccdde2442a163528 /numpy/lib/tests/test_format.py | |
parent | 0752872542593bb8703977d5d1e458dbca0cb712 (diff) | |
download | numpy-a2bd3a7eabfe053d6d16a2130fdcad9e5211f6bb.tar.gz |
ENH: add options for disabling use of pickle in load/save
Diffstat (limited to 'numpy/lib/tests/test_format.py')
-rw-r--r-- | numpy/lib/tests/test_format.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 201ceaddd..4f8a65148 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -599,6 +599,22 @@ def test_pickle_python2_python3(): encoding='latin1', fix_imports=False) +def test_pickle_disallow(): + data_dir = os.path.join(os.path.dirname(__file__), 'data') + + path = os.path.join(data_dir, 'py2-objarr.npy') + assert_raises(ValueError, np.load, path, + allow_pickle=False, encoding='latin1') + + path = os.path.join(data_dir, 'py2-objarr.npz') + f = np.load(path, allow_pickle=False, encoding='latin1') + assert_raises(ValueError, f.__getitem__, 'x') + + path = os.path.join(tempdir, 'pickle-disabled.npy') + assert_raises(ValueError, np.save, path, np.array([None], dtype=object), + allow_pickle=False) + + def test_version_2_0(): f = BytesIO() # requires more than 2 byte for header |