@@ -0,0 +1,812 @@
+# coding: utf-8%0Afrom __future__ import unicode_literals%0A%0Aimport pytest%0A%0Afrom ...tokens.doc import Doc%0Afrom ...vocab import Vocab%0A%0A%0A@pytest.fixture%0Adef doc_w_attrs(en_tokenizer):%0A    Doc.set_extension('_test_attr', default=False)%0A    Doc.set_extension('_test_prop', getter=lambda doc: len(doc.text))%0A    Doc.set_extension('_test_method', method=lambda doc, arg: %22%7B%7D%7B%7D%22.format(len(doc.text), arg))%0A    doc = en_tokenizer(%22This is a test.%22)%0A    doc._._test_attr = 'test'%0A    return doc%0A%0A%0A%0Adef test_serialize_ext_attrs_from_bytes(doc_w_attrs):%0A    doc_b = doc_w_attrs.to_bytes()%0A    doc = Doc(Vocab()).from_bytes(doc_b)%0A    assert doc._.has('_test_attr')%0A    assert doc._._test_attr == 'test'%0A    assert doc._._test_prop == len(doc.text)%0A    assert doc._._test_method('test') == '%7B%7D%7B%7D'.format(len(doc.text), 'test')%0A

Add test for serializing extension attrs (see #1085)