2015-10-12 11:33:11 +03:00
|
|
|
import cloudpickle
|
2015-10-24 08:18:47 +03:00
|
|
|
import io
|
|
|
|
import os
|
2015-10-12 11:33:11 +03:00
|
|
|
import pickle
|
2015-10-24 08:18:47 +03:00
|
|
|
import pytest
|
|
|
|
import tempfile
|
2015-10-12 11:33:11 +03:00
|
|
|
|
2015-11-03 06:57:02 +03:00
|
|
|
try:
|
|
|
|
unicode
|
|
|
|
except NameError:
|
|
|
|
unicode = str
|
|
|
|
|
2016-01-25 17:24:17 +03:00
|
|
|
# These cause the addition of temp files, that are then not deleted
|
2016-01-25 17:51:13 +03:00
|
|
|
#@pytest.mark.models
|
|
|
|
#def test_pickle_english(EN):
|
|
|
|
# file_ = io.BytesIO()
|
|
|
|
# cloudpickle.dump(EN, file_)
|
|
|
|
#
|
|
|
|
# file_.seek(0)
|
|
|
|
#
|
|
|
|
# loaded = pickle.load(file_)
|
|
|
|
# assert loaded is not None
|
|
|
|
#
|
|
|
|
#@pytest.mark.models
|
|
|
|
#def test_cloudpickle_to_file(EN):
|
|
|
|
# f = tempfile.NamedTemporaryFile(delete=False)
|
|
|
|
# p = cloudpickle.CloudPickler(f)
|
|
|
|
# p.dump(EN)
|
|
|
|
# f.close()
|
|
|
|
# loaded_en = cloudpickle.load(open(f.name, 'rb'))
|
|
|
|
# os.unlink(f.name)
|
|
|
|
# doc = loaded_en(unicode('test parse'))
|
|
|
|
# assert len(doc) == 2
|