ModuleNotFoundError and can't run/debug unittest
See original GitHub issueEnvironment data
- VS Code version:
1.60.0
- Extension version (available under the Extensions sidebar):
2021.9.1218897484
- OS and version: MacOS Mojave 10.14.6 (in a Codespace)
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.6 64-bit
- Type of virtual environment used (N/A | venv | virtualenv | conda | …):
pipenv --global
- Relevant/affected Python packages and their versions: N/A
- Relevant/affected Python-related VS Code extensions and their versions: N/A
- Value of the
python.languageServer
setting: not set
Expected behaviour
unittest
tests are automatically detected and show up in testing side bar"
Actual behaviour
They do not, and I get:
Steps to reproduce:
While working on https://github.com/JEFuller/dataclasses-configobj
Running on 2021.9.1191016588
is ✅
but updating to 2021.9.1218897484
is ❌
I can switch between versions and the tests appear and disappear, as show above ⬆️
Logs
Output for Python
in the Output
panel >
/usr/bin/python3 ~/.vscode-remote/extensions/ms-python.python-2021.9.1218897484/pythonFiles/testing_tools/unittest_discovery.py ./tests test_*.py
cwd: /workspaces/dataclasses-configobj
Error 2021-09-10 02:00:49: Error discovering unittest tests:
Failed to import test module: test_core
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/workspaces/dataclasses-configobj/tests/test_core.py", line 7, in <module>
from dataclasses_configobj import core
ModuleNotFoundError: No module named 'dataclasses_configobj'
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:11 (5 by maintainers)
Top Results From Across the Web
IntelliJ Python unittests cannot import modules - Stack Overflow
My final solution is to add the classpath of the module to Run/Debug Configurations: Open Run/Debug Configurations and select your unittest ...
Read more >PyCharm - Run/Debug Configuration: Python Unit Test
You can type in the module name, search the target module by its name, or locate it in the project structure.
Read more >python unittest module not found - You.com | The AI Search ...
Python Unit test module throws "ModuleNotFoundError: No module named ... _accounts: raise ValueError ('Accounts cannot be assigned to the same Market ...
Read more >Set up unit testing for Python code - Visual Studio
Setting up unit testing for Python code in Visual Studio takes full advantage of Test Explorer features to discover, run, and debug tests....
Read more >Developing Python Web Applications with Flask
Flask does not provide an integrated Model (M) layer, and lets you pick ... in your Eclipse PyDev (to avoid the annoying module...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was having the same issue, stumbled upon this page, and for those who still have the same problem: don’t forget to run
pip install
to have your requirements to run your tests 😉This particular issue is fixed. If you are seeing
ModuleNotFoundError
it can be for a variety of reasons. Please file a separate bug with details so we can investigate.