title: Doctest not working in Sphinx, cannot import python files Python
body: <p>I have a problem trying to run <code>doctest</code> from the <a href="https://www.sphinx-doc.org/en/master/tutorial/describing-code.html" rel="nofollow noreferrer">Sphinx Tutorial</a>. I have the directory tree below but I cannot run a <code>doctest</code> for <code>lumache.py</code>. How would be able to make it so that <code>lumache.py</code> is importable with the <code>pathlib</code> function in <code>conf.py</code> which is <code>sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())</code>.The code I am trying to execute is of the same one from the tutorial (hyperlink mentioned in the first sentence).</p>
  <p><strong>conf.py Contents</strong></p>
  <pre><code># If extensions (or modules to document with autodoc) are in another directory,
  # add these directories to sys.path here.
  import pathlib
  import sys
  sys.path.insert(0, pathlib.Path(__file__).parents[2].resolve().as_posix())
  
  extensions = [
      'sphinx.ext.duration',
      'sphinx.ext.doctest',
  ]
  
  ...
  </code></pre>
  <p><strong>Contents of</strong> <code>lumache.py</code></p>
  <pre><code>def get_random_ingredients(kind=None):
      return [&quot;shells&quot;, &quot;gorgonzola&quot;, &quot;parsley&quot;]
  </code></pre>
  <p><strong>CMD execution</strong></p>
  <pre><code>C:\docs&gt;make doctest
  ModuleNotFoundError: No module named 'lumache'
  </code></pre>
  <p><strong>Directory Tree:</strong></p>
  <pre><code>docs/
  ├─build/
  │ ├─doctest/
  │ │ └─0 folder(s), 1 file(s)
  │ ├─doctrees/
  │ │ └─0 folder(s), 3 file(s)
  │ └─html/
  │   └─3 folder(s), 7 file(s)
  ├─make.bat
  ├─Makefile
  └─source/
    ├─conf.py
    ├─index.rst
    ├─lumache.py
    ├─usage.rst
    ├─_static/
    │ └─0 folder(s), 0 file(s)
    └─_templates/
      └─0 folder(s), 0 file(s)
  </code></pre>