From 8ca97f32a3fa5af7d20937f63430a5d809c5f575 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 17 Oct 2017 18:19:57 +0200 Subject: [PATCH] Fix doc pickling test --- spacy/tests/doc/test_pickle_doc.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spacy/tests/doc/test_pickle_doc.py b/spacy/tests/doc/test_pickle_doc.py index 81ce22666..9bfa442d9 100644 --- a/spacy/tests/doc/test_pickle_doc.py +++ b/spacy/tests/doc/test_pickle_doc.py @@ -1,8 +1,7 @@ from __future__ import unicode_literals -import pickle - from ...language import Language +from ...compat import pickle, unicode_ def test_pickle_single_doc(): @@ -15,11 +14,13 @@ def test_pickle_single_doc(): def test_list_of_docs_pickles_efficiently(): nlp = Language() + for i in range(10000): + _ = nlp.vocab[unicode_(i)] one_pickled = pickle.dumps(nlp(u'0'), -1) - docs = list(nlp.pipe(str(i) for i in range(100))) + docs = list(nlp.pipe(unicode_(i) for i in range(100))) many_pickled = pickle.dumps(docs, -1) assert len(many_pickled) < (len(one_pickled) * 2) many_unpickled = pickle.loads(many_pickled) assert many_unpickled[0].text == '0' assert many_unpickled[-1].text == '99' - assert len(many_unpickled) == 99 + assert len(many_unpickled) == 100