code: def test_sentiment_comment(doc):
      """
      Test that setting the sentiment on a doc sets the sentiment comment
      """
      for sentence in doc.sentences:
          assert (
              len(
                  [
                      x
                      for x in sentence.comments
                      if x.startswith("# sentiment")
                  ]
              )
              == 0
          )
  
      # currently nothing is checking that the items are actually trees
      sentiments = ["1", "2"]
      doc.set(fields=SENTIMENT, contents=sentiments, to_sentence=True)
  
      for sentence, expected in zip(doc.sentences, sentiments):
          sentiment_comments = [
              x
              for x in sentence.comments
              if x.startswith("# sentiment")
          ]
          assert len(sentiment_comments) == 1
          assert sentiment_comments[0].endswith(expected)
  
      # Test that if we replace the trees with an updated tree, the comment is also replaced
      sentiments = ["3", "4"]
      doc.set(fields=SENTIMENT, contents=sentiments, to_sentence=True)
  
      for sentence, expected in zip(doc.sentences, sentiments):
          sentiment_comments = [
              x
              for x in sentence.comments
              if x.startswith("# sentiment")
          ]
          assert len(sentiment_comments) == 1
          assert sentiment_comments[0].endswith(expected)
  
file_path: stanza/stanza/tests/common/test_doc.py
imports: import pytest
  import stanza
  from stanza.tests import *
  from stanza.models.common.doc import Document, ID, TEXT, NER, CONSTITUENCY, SENTIMENT
label_desc: Use image node_id 7 for calling a global function with example usage: test_sentiment_comment(doc) without return types