We’re excited to announce the September 2024 release of the Python and Jupyter extensions for Visual Studio Code!
This release includes the following announcements:
- Django unit test support
- Go to definition from inlay hints with Pylance
If you’re interested, you can check the full list of improvements in our changelogs for the Python, Jupyter and Pylance extensions.
Django unit test support
We are excited to announce support for one of our most requested features: you can now discover and run Django unit tests through the Test Explorer!
In order to enable this feature, you will need to add a MANAGE_PY_PATH
environment variable, pointing to your Django application’s manage.py file. To do so, you can follow these steps:
- Set
"python.testing.unittestEnabled": true,
in yoursettings.json
file. - Add
MANAGE_PY_PATH
as an environment variable:- Create a
.env
file at the root of your project. - Add
MANAGE_PY_PATH='<path-to-manage.py>'
to the.env
file, replacing<path-to-manage.py>
with the path to your application’smanage.py
file.Tip: You can copy the path by right clicking on the file in the Explorer view and selecting Copy Path.
- Create a
- Add Django test arguments to
"python.testing.unittestArgs": []
in thesettings.json
file as needed, and remove any arguments that are not compatible with Django.
Note: By default, the Python extension looks for and loads
.env
files at the project root. If your.env
file is not at the project root or you are using VS Code variable substitution, add"python.envFile": "${workspaceFolder}/<path-to-.env>"
to yoursettings.json
file, so the Python extension can load the environment variables in this file when running and discovering tests. See our Python environment variables docs for more information on environment variables.
Navigate to the Testing view, and select the Refresh Tests button to have your Django tests displayed!
For troubleshooting tips, please see our Django testing docs. As you explore this newly added feature, please provide feedback and report any issues in our vscode-python repo or by using the Python: Report Issue command.
Go to definition from inlay hints with Pylance
When enabling inlay hints with Pylance, you can now more conveniently navigate to a type’s definition through Ctrl+Click
or Cmd+Click
when hovering over it.
Other Changes and Enhancements
We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python and Jupyter Notebooks in Visual Studio Code. Some notable changes include:
- You can now access the VS Code Native REPL for Python from the Command Palette (
Ctrl/Cmd + Shift + P
) usingPython: Start Native REPL
(@vscode-python#23727) - VS Code Native REPL for Python now starts at the project folder (@vscode-python#23821)
- Strings are now normalized when sending commands to the VS Code Native REPL (@vscode-python#23743)
- You can now restart the debugger when debugging tests through the debug control widget (@vscode-python#23752)
Call for Community Feedback
As we are planning and prioritizing future work, we value your feedback! Below are a few issues we would love feedback on:
- Design proposal for test coverage in (@vscode-python#22827)
Try out these new improvements by downloading the Python extension and the Jupyter extension from the Marketplace, or install them directly from the extensions view in Visual Studio Code (Ctrl + Shift + X or ⌘ + ⇧ + X). You can learn more about Python support in Visual Studio Code in the documentation. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.
Please, what is the theme you are using in the Django unit test screenshot?
Hi, the theme used is Catppuccin Macchiato (preview on vscode.dev)!
Thank you!!