code: def test_doc_to_json_underscore_error_serialize(doc):
      """Test that Doc.to_json() raises an error if a custom attribute value
      isn't JSON-serializable."""
      Doc.set_extension("json_test4", method=lambda doc: doc.text)
      with pytest.raises(ValueError):
          doc.to_json(underscore=["json_test4"])
  
imports: import pytest
  import srsly
  import spacy
  from spacy import schemas
  from spacy.tokens import Doc, Span, Token
  from .test_underscore import clean_underscore
label_desc: Use image node_id 11 for calling a global function with example usage: test_doc_to_json_underscore_error_serialize(doc) without return types