code: def test_call_decorated_on_trait_change(clear_display):
      """test calling @interact decorated functions"""
      d = {}
      with patch.object(interaction, "display", record_display):
  
          @interact
          def foo(a="default"):
              d["a"] = a
              return a
  
      assert len(displayed) == 1
      w = displayed[0].children[0]
      check_widget(
          w,
          cls=widgets.Text,
          value="default",
      )
      # test calling the function directly
      a = foo("hello")
      assert a == "hello"
      assert d["a"] == "hello"
  
      # test that setting trait values calls the function
      with patch.object(interaction, "display", record_display):
          w.value = "called"
      assert d["a"] == "called"
      assert len(displayed) == 2
      assert w.value == displayed[-1]
  
imports: from __future__ import print_function
  import os
  from collections import OrderedDict
  import pytest
  import ipywidgets
  from traitlets import TraitError
  from ipywidgets import interact, interact_manual, interactive, interaction, Output
  from ipython_genutils.py3compat import annotate
  from .utils import setup, teardown
label_desc: Use image node_id 30 for calling a global function with example usage: test_call_decorated_on_trait_change(clear_display) and returns: a