Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New Method for Output Handling in Python Testing

Eleanor Boyd edited this pageOct 11, 2023 ·5 revisions

What Has Changed?

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 thePython Test Logs output channel located under theOutput tab in the Workbench (please refer to the images below for visual reference to the different UI elements discussed here). Now, thetesting discovery output will be located in thePython output channel, while theoutput from test execution will be found in theTest 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:ptyhon test logs highlighted in red box

All discovery output will output in thePython log like so:python output channel highlighted in red box

All run output will be in theTest Results Panel:test result panel shown in toolbar

Individual run items, shown clicked below, will have error messages and stack traces.individual output for test in Test Result panel

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 iconright-click menu
terminal icon on menu item for outputright click menu item for output

Why Was This Change Implemented?

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 anissue or post aQ&A with any concerns regarding this design change, happy coding!

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp