title: How to get VSCode Python extension recognize submodules when running unittest test cases?
body: <p><strong>Problem</strong></p>
  <p>I cannot get VSCode/unittest to recognize submodules (i.e., <code>common.nested_module</code> in the example in background) that I wrote unittests for.</p>
  <p>VSCode discovers the tests cases and executes those in <code>test_my_module.py</code> but complains that there is no module <code>common.nested_module</code> on the <code>import</code> statement line in <code>test_nested_module.py</code> (in Output: <code>ModuleNotFoundError: No module named 'common.nested_module'</code>).</p>
  <p>I added <code>print(sys.path)</code> to the executed test case and in Python Test log I even get the following output when adding <code>.env</code> file as described below in <em>What I tried 2.</em>:</p>
  <pre><code>test_get_version (test_my_module.TestCase1) ... ['/workspaces/test_project/project/tests', '/workspaces/test_project/project/src', '/workspaces/test_project/project/common', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/home/vscode/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/site-packages']
  </code></pre>
  <p><strong>Background</strong></p>
  <p>Following the <a href="https://packaging.python.org/tutorials/packaging-projects/" rel="nofollow noreferrer">PyPA tutorial for packaging and distribution</a> I created a project structure, leaving out other details (e.g., <code>README.md</code>), as follows:</p>
  <pre><code>project
     |--src
        |--common
            |-- __init__.py
            |-- nested_module.py
        |-- __init__.py
        |-- my_module.py
     |--tests
        |--__init__.py
        |--test_my_module.py
        |--test_nested_module.py
  </code></pre>
  <p>Settings related to testing in <code>settings.json</code>:</p>
  <pre class="lang-json prettyprint-override"><code>{
      &quot;python.testing.unittestArgs&quot;: [
          &quot;-v&quot;,
          &quot;-s&quot;,
          &quot;${workspaceFolder}/project/tests&quot;,
          &quot;-p&quot;,
          &quot;test_*.py&quot;
      ],
      &quot;python.testing.cwd&quot;: &quot;project/src&quot;,
      &quot;python.testing.pytestEnabled&quot;: false,
      &quot;python.testing.unittestEnabled&quot;: true,
  }
  </code></pre>
  <p><strong>What I tried</strong></p>
  <ol>
  <li>Adding the following to my <code>__init__.py</code> in <code>project/tests</code> as well as to <code>test_nested_module.py</code> as suggested <a href="https://stackoverflow.com/questions/1896918/running-unittest-with-typical-test-directory-structure">here</a>.</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>
  import os
  import sys
  PROJECT_PATH = os.getcwd()
  SOURCE_PATH = os.path.join(
      PROJECT_PATH,&quot;project/src/common&quot;
  )
  sys.path.append(SOURCE_PATH)
  </code></pre>
  <ol start="2">
  <li>Adding an <code>.env</code> to <code>project</code> containing the following while adding <code>&quot;python.envFile&quot;: &quot;${workspaceFolder}/afinad/.env&quot;</code> to <code>settings.json</code> similar to what was suggested <a href="https://stackoverflow.com/questions/1896918/running-unittest-with-typical-test-directory-structure">here</a>.</li>
  </ol>
  <pre><code>PYTHONPATH = ./common
  </code></pre>
  <ol start="3">
  <li>Adding <code>-t</code> option with <code>${workspaceFolder}/project/src</code> and <code>.</code> to <code>settings.json</code> for <code>python.testing.unittestArgs</code> as sggested <a href="https://github.com/microsoft/vscode-python/issues/6881" rel="nofollow noreferrer">here</a>:</li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>
  &quot;python.testing.unittestArgs&quot;: [
          &quot;-v&quot;,
          &quot;-s&quot;,
          &quot;${workspaceFolder}/project/tests&quot;,
          &quot;-p&quot;,
          &quot;test_*.py&quot;,
          &quot;-t&quot;,
          &quot;${workspaceFolder}/project/src&quot;
      ],
  </code></pre>
  <ol start="3">
  <li>Running <code>python3 -m unittest discover</code> after changing into <code>./tests</code> in terminal gives me:</li>
  </ol>
  <pre><code>ModuleNotFoundError: No module named 'my_module'
  </code></pre>
  <p><strong>Thanks for taking time to read. Any help is much appreciated!</strong></p>