test_numpy_pickle_compat.py 609 B

12345678910111213141516
  1. """Test the old numpy pickler, compatibility version."""
  2. # numpy_pickle is not a drop-in replacement of pickle, as it takes
  3. # filenames instead of open files as arguments.
  4. from joblib import numpy_pickle_compat
  5. def test_z_file(tmpdir):
  6. # Test saving and loading data with Zfiles.
  7. filename = tmpdir.join("test.pkl").strpath
  8. data = numpy_pickle_compat.asbytes("Foo, \n Bar, baz, \n\nfoobar")
  9. with open(filename, "wb") as f:
  10. numpy_pickle_compat.write_zfile(f, data)
  11. with open(filename, "rb") as f:
  12. data_read = numpy_pickle_compat.read_zfile(f)
  13. assert data == data_read