code: def test_extra_referrer_error(
      self, caplog: pytest.LogCaptureFixture
  ) -> None:
      d = Document()
      dm = bdm.DocumentModuleManager(d)
  
      mod = FakeMod()
      assert "FakeMod" not in sys.modules
  
      dm.add(mod)
  
      assert "FakeMod" in sys.modules
      assert len(dm) == 1
  
      # add an extra referrer for Document.destroy to complain about
      extra.append(mod)
  
      import gc
  
      # get_referrers behavior changed in Python 3.7, see https://github.com/bokeh/bokeh/issues/8221
      assert len(gc.get_referrers(mod)) in (3, 4)
  
      with caplog.at_level(logging.ERROR):
          dm.destroy()
          assert (
              "Module %r has extra unexpected referrers! This could indicate a serious memory leak. Extra referrers:"
              % mod
              in caplog.text
          )
          assert len(caplog.records) == 1
  
      assert "FakeMod" not in sys.modules
      assert len(dm) == 0
  
file_path: bokeh/tests/unit/bokeh/document/test_modules.py
imports: from __future__ import annotations
  import pytest
  import gc
  import logging
  import sys
  from bokeh.document import Document
  from bokeh.util.logconfig import basicConfig
  import bokeh.document.modules
label_desc: Use image node_id 5 for calling the TestDocumentModuleManager obj's underlying member method code with example usage: obj.test_extra_referrer_error(caplog) without return types