Test that user_data is correctly serialized in DocBin.
(en_vocab)
| 16 | |
| 17 | @pytest.mark.issue(4528) |
| 18 | def test_issue4528(en_vocab): |
| 19 | """Test that user_data is correctly serialized in DocBin.""" |
| 20 | doc = Doc(en_vocab, words=["hello", "world"]) |
| 21 | doc.user_data["foo"] = "bar" |
| 22 | # This is how extension attribute values are stored in the user data |
| 23 | doc.user_data[("._.", "foo", None, None)] = "bar" |
| 24 | doc_bin = DocBin(store_user_data=True) |
| 25 | doc_bin.add(doc) |
| 26 | doc_bin_bytes = doc_bin.to_bytes() |
| 27 | new_doc_bin = DocBin(store_user_data=True).from_bytes(doc_bin_bytes) |
| 28 | new_doc = list(new_doc_bin.get_docs(en_vocab))[0] |
| 29 | assert new_doc.user_data["foo"] == "bar" |
| 30 | assert new_doc.user_data[("._.", "foo", None, None)] == "bar" |
| 31 | |
| 32 | |
| 33 | @pytest.mark.issue(5141) |
nothing calls this directly
no test coverage detected
searching dependent graphs…