code: def test_mocked_module_imports(app, warning):
      sys.modules.pop(
          "target", None
      )  # unload target module to clear the module cache
  
      # no autodoc_mock_imports
      options = {"members": "TestAutodoc,decoratedFunction,func,Alias"}
      actual = do_autodoc(app, "module", "target.need_mocks", options)
      assert list(actual) == []
      assert (
          "autodoc: failed to import module 'need_mocks'"
          in warning.getvalue()
      )
  
      # with autodoc_mock_imports
      app.config.autodoc_mock_imports = [
          "missing_module",
          "missing_package1",
          "missing_package2",
          "missing_package3",
          "sphinx.missing_module4",
      ]
  
      warning.truncate(0)
      actual = do_autodoc(app, "module", "target.need_mocks", options)
      assert list(actual) == [
          "",
          ".. py:module:: target.need_mocks",
          "",
          "",
          ".. py:data:: Alias",
          "   :module: target.need_mocks",
          "",
          "   docstring",
          "",
          "",
          ".. py:class:: TestAutodoc()",
          "   :module: target.need_mocks",
          "",
          "   TestAutodoc docstring.",
          "",
          "",
          "   .. py:attribute:: TestAutodoc.Alias",
          "      :module: target.need_mocks",
          "",
          "      docstring",
          "",
          "",
          "   .. py:method:: TestAutodoc.decoratedMethod()",
          "      :module: target.need_mocks",
          "",
          "      TestAutodoc::decoratedMethod docstring",
          "",
          "",
          ".. py:function:: decoratedFunction()",
          "   :module: target.need_mocks",
          "",
          "   decoratedFunction docstring",
          "",
          "",
          ".. py:function:: func(arg: missing_module.Class)",
          "   :module: target.need_mocks",
          "",
          "   a function takes mocked object as an argument",
          "",
      ]
      assert warning.getvalue() == ""
  
imports: import platform
  import sys
  from contextlib import contextmanager
  import pytest
  from sphinx.testing import restructuredtext
  from tests.test_extensions.test_ext_autodoc import do_autodoc
label_desc: Use image node_id 14 for calling a global function with example usage: test_mocked_module_imports(app, warning) without return types