code: def test_patch_curdoc() -> None:
      d1 = Document()
      d2 = Document()
      orig_doc = bid.curdoc()
  
      assert bid._PATCHED_CURDOCS == []
  
      with bid.patch_curdoc(d1):
          assert len(bid._PATCHED_CURDOCS) == 1
          assert isinstance(
              bid._PATCHED_CURDOCS[0], weakref.ReferenceType
          )
          assert bid.curdoc() is d1
  
          with bid.patch_curdoc(d2):
              assert len(bid._PATCHED_CURDOCS) == 2
              assert isinstance(
                  bid._PATCHED_CURDOCS[1], weakref.ReferenceType
              )
              assert bid.curdoc() is d2
  
          assert len(bid._PATCHED_CURDOCS) == 1
          assert isinstance(
              bid._PATCHED_CURDOCS[0], weakref.ReferenceType
          )
          assert bid.curdoc() is d1
  
      assert bid.curdoc() is orig_doc
  
file_path: bokeh/tests/unit/bokeh/io/test_doc.py
imports: from __future__ import annotations
  import pytest
  import weakref
  from bokeh.document import Document
  from bokeh.io.state import curstate
  import bokeh.io.doc
label_desc: Use image node_id 3 for calling a global function with example usage: test_patch_curdoc() without return types