Given a project structure:
* project
* src
* my_package
* __init__.py
* code_file.py
* tests
* __init__.py
* my_package
* __init__.py
* code_file_test.py
How do I get Visual Studio code to identify that src is the root for code files so this will work for all of these:
intellisense
running
discovering and running tests
In IntelliJ so can right click the
srcfolder and mark it as the source root. There is no simple solution in VSC, however, this workaround could help.Under the project root add the following file:
.vscode/settings.jsonwith the following content:
(The two last parameters assume you are using the
unittestpython framework, change if using another one.)If this doesn't work, make sure you have the following extensions installed:
If the above doesn't work, try restarting VSC, if that doesn't work, you may have to alter imports like this...
In
srccode:In
testscode: