docstr: Deltas should only be coalesced if they're in the same container
docstr_tok: ["Deltas","should","only","be","coalesced","if","they","'re","in","the","same","container"]
code: def test_multiple_containers(self):
      """Deltas should only be coalesced if they're in the same container"""
      rq = ForwardMsgQueue()
      self.assertTrue(rq.is_empty())
  
      rq.enqueue(NEW_SESSION_MSG)
  
      def enqueue_deltas(container: int, path: Tuple[int, ...]):
          # We deep-copy the protos because we mutate each one
          # multiple times.
          msg = copy.deepcopy(TEXT_DELTA_MSG1)
          msg.metadata.delta_path[:] = make_delta_path(
              container, path, 0
          )
          rq.enqueue(msg)
  
          msg = copy.deepcopy(DF_DELTA_MSG)
          msg.metadata.delta_path[:] = make_delta_path(
              container, path, 1
          )
          rq.enqueue(msg)
  
          msg = copy.deepcopy(ADD_ROWS_MSG)
          msg.metadata.delta_path[:] = make_delta_path(
              container, path, 1
          )
          rq.enqueue(msg)
  
      enqueue_deltas(RootContainer.MAIN, ())
      enqueue_deltas(RootContainer.SIDEBAR, (0, 0, 1))
  
      def assert_deltas(
          container: int, path: Tuple[int, ...], idx: int
      ):
          # Text delta
          self.assertEqual(
              make_delta_path(container, path, 0),
              queue[idx].metadata.delta_path,
          )
          self.assertEqual(
              "text1", queue[idx].delta.new_element.text.body
          )
  
      queue = rq.flush()
      self.assertEqual(7, len(queue))
  
      assert_deltas(RootContainer.MAIN, (), 1)
      assert_deltas(RootContainer.SIDEBAR, (0, 0, 1), 4)
  
file_path: streamlit/lib/tests/streamlit/runtime/forward_msg_queue_test.py
imports: import copy
  import unittest
  from typing import Tuple
  from parameterized import parameterized
  from streamlit.cursor import make_delta_path
  from streamlit.elements import arrow
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.proto.RootContainer_pb2 import RootContainer
  from streamlit.runtime.forward_msg_queue import ForwardMsgQueue
label_desc: Use image node_id 6 for calling the ForwardMsgQueueTest obj's underlying member method code with example usage: obj.test_multiple_containers() without return types