class_docstr: test layout templates
docstr: test whether it's possible to add widget outside __init__
docstr_tok: ["test","whether","it","'s","possible","to","add","widget","outside","__init__"]
code: def test_update_dynamically(
      self, send_state
  ):  # pylint: disable=no-self-use
      """test whether it's possible to add widget outside __init__"""
  
      button1 = widgets.Button()
      button2 = widgets.Button()
      button3 = widgets.Button()
      button4 = widgets.Button()
  
      box = widgets.TwoByTwoLayout(
          top_left=button1,
          top_right=button3,
          bottom_left=None,
          bottom_right=button4,
      )
      from ipykernel.kernelbase import Kernel
  
      state = box.get_state()
      assert len(state["children"]) == 3
      assert box.layout.grid_template_areas == (
          '"top-left top-right"\n' + '"top-left bottom-right"'
      )
  
      box.layout.comm.kernel = mock.MagicMock(
          spec=Kernel
      )  # for mocking purposes
      send_state.reset_mock()
      box.bottom_left = button2
  
      state = box.get_state()
      assert len(state["children"]) == 4
      assert box.layout.grid_template_areas == (
          '"top-left top-right"\n' + '"bottom-left bottom-right"'
      )
      # check whether frontend was informed
      send_state.assert_called_once_with(key="grid_template_areas")
  
      box = widgets.TwoByTwoLayout(
          top_left=button1,
          top_right=button3,
          bottom_left=None,
          bottom_right=button4,
      )
      assert box.layout.grid_template_areas == (
          '"top-left top-right"\n' + '"top-left bottom-right"'
      )
      box.layout.comm.kernel = mock.MagicMock(
          spec=Kernel
      )  # for mocking purposes
      send_state.reset_mock()
      box.merge = False
      assert box.layout.grid_template_areas == (
          '"top-left top-right"\n' + '"bottom-left bottom-right"'
      )
      send_state.assert_called_once_with(key="grid_template_areas")
  
imports: from unittest import TestCase
  import pytest
  import traitlets
  import ipywidgets
  from ipywidgets.widgets.widget_templates import LayoutProperties
label_desc: Use image node_id 4 for calling the TestTwoByTwoLayout obj's underlying member method code with example usage: obj.test_update_dynamically(send_state) without return types