-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New Method for Output Handling in Python Testing
As part of the Python extension's testing infrastructure overhaul, the testing output has also undergone a redesign to improve the compatibility with VS Code tools and its interface. Previously, all testing output, both the output generated during test discovery and execution, was printed into the Python Test Logs
output channel located under the Output
tab in the Workbench (please refer to the images below for visual reference to the different UI elements discussed here). Now, the testing discovery output will be located in the Python
output channel, while the output from test execution will be found in the Test Results
panel within the Workbench. This modification reduces the number of places that users need to reference while running and debugging their tests. Discovery output logging will be captured at the "Trace" level, while errors occurring during discovery will remain at the "Error Log" level.
Output for execution is managed by the testing libraries themselves, namely unittest or pytest, so any adjustments to log levels or verbosity should be made within these libraries. On the Test Result panel, each test now has its own item nested under the general run call menu item. Just as before, clicking on the nested test item will display the message specific to that particular test, a feature that only applies to failed tests. To access all the output from the entire test run, you can either right-click on the parent test menu item or use the console icon next to it. Output will still appear in "Python Test Logs" for now as we complete the transition to these new output locations.
The highlighted output channel will be removed in a month after the transitional period is over:
All discovery output will output in the Python
log like so:
All run output will be in the Test Results
Panel:
Individual run items, shown clicked below, will have error messages and stack traces.
Overall output returned per run and will be displayed as part of the header item. This output will appear after the run but can also be accessed via the terminal icon and the right-click menu.
terminal icon | right-click menu |
---|---|
In the previous design of testing within the extension, all output was read and parsed to populate the testing user interface, such as the Test Result panel and the Test Explorer. In the rewrite, this is no longer necessary because the information required to populate the user interface is communicated over a socket. With this change, the extension no longer needs to control the output for information digestion, and we are now returning full control to the user regarding the appearance of their output. This increased flexibility enables information to be presented in line with VS Code's design principles, keeping Python output consolidated within a single channel and Python testing output integrated with all test results. Additionally, this change allows the use of the --color=yes
argument to color output of as pytest does in the command line normally.
As always, you can file an issue or post a Q&A with any concerns regarding this design change, happy coding!