Test pickling hooks

This commit is contained in:
Matthew Honnibal 2017-10-17 19:43:52 +02:00
parent cdb0c426d8
commit fe844148f6

View File

@ -41,3 +41,14 @@ def test_user_data_unpickles():
b = pickle.dumps(doc)
doc2 = pickle.loads(b)
assert doc2.user_data[(0, 1)] == False
def test_hooks_unpickle():
def inner_func(d1, d2):
return 'hello!'
nlp = Language()
doc = nlp(u'Hello')
doc.user_hooks['similarity'] = inner_func
b = pickle.dumps(doc)
doc2 = pickle.loads(b)
assert doc2.similarity(None) == 'hello!'