Repository navigation
Future Design of Python Testing Output #21861
Description
The following issue describes the current behavior and outlines a few questions that need to be figured out to write a proposal.
Current Behavior (pre-rewrite)
Currently, there are three places where users can view different output types from their test run. First is the "python test log" under the output panel, second is the "Test Result" panel, and finally the in-line pop-up for failed tests. The "Test Result" panel and the in-line pop-up are identical in output (when the in-line is displayed since it isn't displayed on pass). Therefore for this discussion, we will just consider the "python test log" and the "Test Result" panel but all things printed to the "Test Result" panel will show up on the in-line pop-up if changes are made.
Due to prior constraints, the extension used to parse output to determine the result of test run and update the UI. This is the primary reason for the two different output views but due to the testing rewrite this is no longer a constraint. This means a decision needs to be made moving forward regarding these two channels and their information.
The current difference between the two are noted below:
| Item | "python test log" | Test Result panel |
|---|---|---|
| print statements (when applicable) | ✅ | ❌ |
| test args | ❌ | ✅ |
| cwd / rootdir | ✅ | ✅ |
| workspace directory | ❌ | ✅ |
| failure message | ❌ | ✅ |
| test summary (section that goes "Total number of tests expected to run: 1.....") | ❌ | ✅ |
| ------ Captured stdout call ------- | ✅ | ❌ |
| =========== short test summary info ============== | ||
| FAILED test_output_types.py::test_print_fail - assert False | ✅ | ❌ |
| config file | ✅ | ❌ |
| platform / pytest version | ✅ | ❌ |
| # tests passed, # failed, # skipped, time taken (ex === 1 passed in 0.01s ====) | ✅ | ❌ |
comparison on the differences just as text for a test that fails and has a print statement. (right: python test output, left: Test Result)

comparison on the difference just as text for a test that fails with logging enabled. (right: python test output, left: Test Result)

Moving Forward
The following questions arise after the above analysis. Please add your feedback in comments below.
- Would be better if we could instead switch all the necessary information to the Test Result panel? If we do this then do we even need the "python test output"?
- If we want to keep the two then what is the difference between them?
- What of the given information is most useful? Should we have the Test Results panel look as similar to the pytest output as possible (like what pytest returns to the command line)? If we do this do we still want custom additions to the Test Result panel such as "workspace directory", "args", and "test summary (section that goes "Total number of tests expected to run: 1.....")"?
- When we do these types of changes what should the "show output button on the testing explorer go to? What should tests open on default when test run finish? Are there any more commands / ways to pull up these different outputs that should be added?
Pros and Cons
- If we switch to using the Test Result panel then we can support color in the output since it's all parsed by xterm.js
The following issues are related to this spike and those involved in these issues are encouraged to give their opinion. Thanks!
- Add "Python Test Log" to the command palette #21694
- pytest results in VSCode should show logging. #21781
- pytest assertions should generate rich diffs #17112
- Syntax highlighting in the output of tests explorer #17411
- Test runner monopolizes stdin, stdout, stderr #18346
- Open correct position in
Pytest Test Logwith a single click on any test #17371 - Add "Python Test Log" to the command palette #21694
- weird behavior of "Debug Test" using pytest #21833
- Python testing using new EOT token PYTEST - test output #22083
- if we go with the test panel then color will be supported, likely addressing these issues:
Activity
eleanorjboyd commentedon Aug 21, 2023
tagging team for their input: Brett Cannon (@brettcannon) Luciana Abud (@luabud) Courtney Webster (@cwebster-99) Karthik Nadig (@karthiknadig) Kartik Raj (@karrtikr) Paula (@paulacamargo25) Anthony Kim (@anthonykim1) Connor Peet (@connor4312)
eleanorjboyd commentedon Aug 22, 2023
One item Kartik Raj (@karrtikr) brought up was if the Test Result panel is always around or if it goes away. Users should be able to reference these logs not just right after run so the result panel will need to have the same lifespan as the output channel.
brettcannon commentedon Aug 22, 2023
I say just merge it all into the Test Result panel. It's the integrated solution in VS Code for this sort of information.
eleanorjboyd commentedon Aug 23, 2023
another related issue: #17371
eleanorjboyd commentedon Aug 23, 2023
If we got rid of the python test output then this issue will be different as all commands to open the output would then route to the test panel: #21694
connor4312 commentedon Aug 23, 2023
I would like the Test Results view to be the 'one stop shop' for the test experience in VS Code. If there are things that make this prohibitive or undesirable, let me know and we can solve them.
I'm not a pythonista, but one thing I do find useful is test extensions that print the command they're running (or the equivalent command a user could run) for the tests. Sometimes, for whatever reason, I want to run them manually in a terminal.
From my point of view when writing test extensions, my goal for the output is to write human readable data and also not lose information. If there is VS Code API for providing information, such as showing large failure diffs in the TestMessage, then that counts as "not losing information" and I may write a more concise version of that failure into the output.
It seems like "python test output" is a mix of the test output and diagnostic data. I think it's good to have a way to get that diagnostic data, but that could be a "log" type output channel and not something we necessarily direct users to unless they run into problems.
Today the "show output" button always opens the output in the Test Results view. Are you thinking that would be different?
eleanorjboyd commentedon Sep 15, 2023
Based on discussions with team members, the plan is to move fully to the Test Results panel (as we have also confirmed this is feasible) and possible remove the
python test logssection from the output panel. The panel was created to handle engineering constraints which are no longer present with the rewrite.This being said there is one question I have. Discovery (for example pytest discovery which is the equivalent of the command
python -m pytest --collect-only) has output- does it make sense for this output to be put in the test results panel? Below I added an example of what the output of discovery is- this comes from pytest and it is useful as it outlines which tests were found as well as a few other important pieces of information such as the config file being used. Would having test discovery output end up in panel called "Test Results" be confusing for users?Brett Cannon (@brettcannon), Luciana Abud (@luabud), Karthik Nadig (@karthiknadig), Courtney Webster (@cwebster-99) thoughts?
Connor Peet (@connor4312) from a core perspective how challenging would it be to implement given the test result panel is mostly based on the test runner object which handles pass/failure?
brettcannon commentedon Sep 18, 2023
We could stick it in the Python channel of the Output panel since, as you pointed out, the Test Results panel doesn't really have a concept of discovery.
eleanorjboyd commentedon Sep 18, 2023
for clarity on this issue, this is what I mean when I talk about the Test Result Panel,

connor4312 commentedon Sep 18, 2023
Yea, I'm not a fan of the idea of putting it in the Test Results panel.
You could have an output channel, or even a simple memory buffer that's opened in an editor on some command. Up to you.
eleanorjboyd commentedon Sep 18, 2023
Connor Peet (@connor4312) and Brett Cannon (@brettcannon), thanks for the input! Will move forward with keeping discovery in the python output panel thanks!
eleanorjboyd commentedon Sep 20, 2023
What are people's thoughts on using color for the debug console logs? This is what it would look like if pytest was set to color true and it was in debug mode:

connor4312 commentedon Sep 20, 2023
Colors are great, they make output much more readable 👍
brettcannon commentedon Sep 21, 2023
I say we give it a shot and see what users think!
switch testing output to test result panel (#22039)
flying-sheep commentedon Oct 16, 2023
Ah, amazing, with
"python.testing.pytestArgs": ["--color=yes"], I see color in the test output panel.The “Peek View” still doesn’t have color, but that can be deactivated. Thank you!
Merged PR posit-dev/positron-python#244: Merge upstream vscode-python…
Merged PR posit-dev/positron-python#244: Merge upstream vscode-python…