Skip to content

Commit

Permalink
Test Issue #459: Fail to deserialize empty doc
Browse files Browse the repository at this point in the history
  • Loading branch information
honnibal committed Oct 23, 2016
1 parent 49c1179 commit e99b3f5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spacy/tests/serialize/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import pytest

from spacy.tokens import Doc
import spacy.en
from spacy.serialize.packer import Packer


def equal(doc1, doc2):
# tokens
Expand Down Expand Up @@ -84,3 +87,13 @@ def test_serialize_tokens_tags_parse_ner(EN):

doc2 = Doc(EN.vocab).from_bytes(doc1.to_bytes())
equal(doc1, doc2)


def test_serialize_empty_doc():
vocab = spacy.en.English.Defaults.create_vocab()
doc = Doc(vocab)
packer = Packer(vocab, {})
b = packer.pack(doc)
assert b == b''
loaded = Doc(vocab).from_bytes(b)
assert len(loaded) == 0

0 comments on commit e99b3f5

Please sign in to comment.